When starting BrowserSync in "server" mode, the following warning is given:
(node:1362) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: Exited with code 3
browserSync.init() with "server" option configured. Removing server option/configuration gets rid of warning.
Npm [ 3.10.3 ]
[X] linux
[ ] other _(please specify which)_
[ ] API
{cli command here}
browserSync.init({
server: "./web",
port: 8000,
ui: {
port: 8001
}
I can confirm this BUG, same with 6.8.0 and browsersync 2.14 - 2.17.
2.13 works without warning.
I cannot reproduce this bug - it's likely some other module (in your gulp build for example) causing this.
Please try with browser-sync only and you should see this resolved
I'm afraid I don't think this is an external issue, as I can replicate with pure browser-sync when running on a _headless/browserless_ Linux system:
var browserSync = require('browser-sync').create();
browserSync.init({
server: {
baseDir: "./web"
}
});
Which issues warning (but does work):
(node:16004) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: Exited with code 3
Same code on Mac OS has no warning and browser is opened.
Same here. Fresh install of Ubuntu Server 16.04 and only using the CLI option, not Gulp or any other packages.
I'm getting the same error running in a Linux Docker container. If I comment out BrowserSync, the error disappears.
I am getting the same issue, definitely caused by BrowserSync. @shakyShane can we reopen this issue now that many users have chimed in with minimal examples yielding similar results?
Could someone using the API paste the following before Browsersync and paste the results
process.on('unhandledRejection', (reason) => {
console.log('Reason: ' + reason);
});
@shakyShane Unfortunately not much help I'm afraid:
Reason: Error: Exited with code 3
_Purely a guess_, but my hunch is that it's related to trying to open a local browser window. As I've personally only seen it appear on browser-less Linux systems.
@Codelica good call, that seems to be exactly what's going on! I'm using it from a headless Linux VM and setting open to false makes the error disappear!
Okay the problem is here https://github.com/BrowserSync/browser-sync/blob/master/lib/utils.js#L183
We should be adding a catch handler to the promise returned by opn. I'm happy to make a pull request @shakyShane if you tell me what you'd like to happen in this scenario?
@alexturpin add then/catch and just console.log the error with a prefix explaining where the error came from (calling the opn module)
Normally I would suggest something cleaner but in this case the callers of the function are not setup for a promise chain so it's the best we can do for now.
Just pushed #1246. I did as best as I could to preserve current structure but don't hesitate to alter if something could have been done better.
i can confirm it is a bug on Mac OSX Sierra too with all latest packages
Fixed https://github.com/BrowserSync/browser-sync/commit/15e0f1e2fba14d5fece1cc68fab32bf092c05711
released to npm v 2.18.2
Hi, seems that issue is back in 2.26.7
(node:924) UnhandledPromiseRejectionWarning: Error: Exited with code 3
at ChildProcess.<anonymous> (/mnt/c/Users/kursion.000/AppData/Roaming/npm/node_modules/browser-sync/node_modules/opn/index.js:83:13)
at Object.onceWrapper (events.js:288:20)
at ChildProcess.emit (events.js:200:13)
at maybeClose (internal/child_process.js:1021:16)
at Socket.<anonymous> (internal/child_process.js:430:11)
at Socket.emit (events.js:200:13)
at Pipe.<anonymous> (net.js:588:12)
(node:924) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async fun
ction without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:924) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not hand
led will terminate the Node.js process with a non-zero exit code.
Most helpful comment
_Purely a guess_, but my hunch is that it's related to trying to open a local browser window. As I've personally only seen it appear on browser-less Linux systems.