You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm embedding live-server into a Node app and there is an issue with opn preventing graceful shutdown. After dealing with unref / destroying sockets to attempt graceful shutdown as noted in #169 there is still an issue with opn. Basically to get live-server to shutdown gracefully wait: false needs to be added to opn invocation. Setting wait to false will resolve the promise in opnimmediately including a call to cp.unref(). This separates the browser child process from the calling Node app.
Since I am already wrapping live-server to deal with "unreffing" sockets I simply handle launching the browser / usage of opn directly in my wrapper as necessary always passing open: false to live-server.
It seems reasonable to add optional user input into how opn is invoked. This includes extra options and perhaps also could address #154.
In the short term I don't see any problems with adding wait: false to opn invocation though I haven't run the live-server tests with this change.
Just a FYI... If anyone is interested in the wrapper I have created it's on NPM: typhonjs-live-server. It contains the workaround necessary to use live-server and terminate it gracefully when embedded in a Node app in addition to providing a few other utility functions like being able to open the browser at any time. Not that this is important to most, but it also is typhonjs-plugin-manager enabled providing event bindings to control live server. I'll post more documentation soon, but just check out the source code for now: LiveServer.js.
Greets...
live-serveris great; good work...I'm embedding
live-serverinto a Node app and there is an issue withopnpreventing graceful shutdown. After dealing with unref / destroying sockets to attempt graceful shutdown as noted in #169 there is still an issue withopn. Basically to getlive-serverto shutdown gracefullywait: falseneeds to be added toopninvocation. Settingwaitto false will resolve the promise inopnimmediately including a call to cp.unref(). This separates the browser child process from the calling Node app.Since I am already wrapping
live-serverto deal with "unreffing" sockets I simply handle launching the browser / usage ofopndirectly in my wrapper as necessary always passingopen: falsetolive-server.It seems reasonable to add optional user input into how
opnis invoked. This includes extra options and perhaps also could address #154.In the short term I don't see any problems with adding
wait: falsetoopninvocation though I haven't run thelive-servertests with this change.Things would change from current to:
The text was updated successfully, but these errors were encountered: