Service Provider Hook for Server Reloads #4236
mrfelipemartins
started this conversation in
General
Replies: 1 comment
-
When the server reloads, the entire process dies and hence you cannot run any code after that. However, what you need is to implement the |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Description
I propose the addition of a development-specific hook or variable within AdonisJS to identify whether a Provider is being invoked following an HTTP server reload triggered by file changes.
Why this feature is required (specific use-cases will be appreciated)?
In my particular use-case, I've implemented a Service Provider responsible for initializing a Puppeteer browser instance that is accessible application-wide through a singleton. During development, when code changes prompt the HTTP server to restart (as expected), the Service Provider is re-invoked, leading to the creation of additional Puppeteer instances without properly closing the previous ones. Regrettably, attempts to manage this within the shutdown method or by utilizing global variables have proven ineffective. Consequently, I find myself contending with numerous open browsers, necessitating manual closure each time a file modification occurs. I am confident that this issue extends beyond my specific use-case.
Have you tried any other work arounds?
Yes, I've explored employing the shutdown hook within the Provider and have also experimented with the implementation of global variables aimed at signaling whether the Provider has been previously initialized.
Are you willing to work on it with little guidance?
Absolutely! Despite being relatively new to Adonis, I possess substantial experience with Node.js, TypeScript, and related technologies. Provided there's consensus on its necessity, I'm more than open to receiving minimal guidance throughout the process to work on this.
Beta Was this translation helpful? Give feedback.
All reactions