Browser-sync: Startup in "server" mode gives "UnhandledPromiseRejectionWarning" in Node 6.7.0

Created on 12 Oct 2016  路  16Comments  路  Source: BrowserSync/browser-sync

Issue details

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

Steps to reproduce/test case

browserSync.init() with "server" option configured. Removing server option/configuration gets rid of warning.

Please specify which version of Browsersync, node and npm you're running

  • Browsersync [ 2.17.3 ]
  • Node [ 6.7.0 ]
  • Npm [ 3.10.3 ]

    Affected platforms

  • [X] linux

  • [? ] windows
  • [? ] OS X
  • [? ] freebsd
  • [? ] solaris
  • [ ] other _(please specify which)_

    Browsersync use-case

  • [ ] API

  • [X] Gulp
  • [ ] Grunt
  • [ ] CLI

    If CLI, please paste the entire command below

{cli command here}

for all other use-cases, (gulp, grunt etc), please show us exactly how you're using Browsersync

  browserSync.init({
      server: "./web",
      port: 8000,
      ui: {
        port: 8001
      }

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.

All 16 comments

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

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.
Was this page helpful?
0 / 5 - 0 ratings