Skip to content

UnhandledPromiseRejectionWarning on Node 7.7.2 #1776

Description

@cschroeter

Description

Bug

Expected behavior

npm start

should not return a UnhandledPromiseRejectionWarning

Actual behavior

cschroeter@pc:~/workspace/my-first-react-app$ npm start

> test@0.1.0 start /home/cschroeter/workspace/my-first-react-app
> react-scripts start

(node:1863) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): TypeError: "listener" argument must be a function
(node:1863) DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Environment

Run these commands in the project folder and fill in their results:

  1. npm ls react-scripts (if you haven’t ejected):
cschroeter@pc:~/workspace/my-first-react-app$ npm ls react-scripts
my-frist-react-app@0.1.0 /home/cschroeter/workspace/my-frist-react-app
└── react-scripts@0.9.4
  1. node -v:
v7.7.2
  1. npm -v:
4.3.0

Then, specify:

  1. Operating system:
    Windows 10 in Linux Bash Shell Build 15048 (Creator Update)

To Reproduce

$ create-react-app my-first-react-app
$ cd my-first-react-app
$ npm start

Activity

  1. whelmich commented on Mar 9, 2017

    @whelmich

    Can reproduce in Linux Mint 18.1 with the same node/npm versions.

    Problem can be resolved by downgrading node to 7.7.1 or older. The problem appeared after upgrading node to 7.7.2.

  2. whelmich commented on Mar 9, 2017

    @whelmich

    This problem seems to be caused by detect-port:1.0.1, used by react-scripts. It causes an error in detect-port/lib/detect-port.js on line 61 socket.connect(...).

    detect-port is currently at version 1.1.0 which features a different approach of port detection. This version resolves the error for node v7.7.2, and also works with 7.6.0 and 7.7.1.

    The Travis build test of version 1.1.0 of detect-port seems to fail, because the test is using node v4.8.0. On node 7.6.0, 7.7.1 and 7.7.2 the tests complete without any problems.

    As the minimum node version of react-scripts is >=4 I am not sure if upgrading the version of detect-port in package.json in react-scripts is an acceptable solution as detect-ports:1.1.0 only passes its test on node version >=6.

  3. Timer commented on Mar 9, 2017

    @Timer
    Contributor

    We do not support Node 7, so the official recommendation would be to downgrade to the latest LTS.
    Currently, that is Node v6.10.0.

    However, we understand this might be desirable. Would one of you like to send a PR adding Node 7 to the CI (only one of the test cases) and resolving this issue?
    Thanks!

    /cc @whelmich

  4. added this to the 0.9.5 milestone on Mar 9, 2017
  5. gaearon commented on Mar 9, 2017

    @gaearon
    Contributor

    (We definitely should support Node 7 tho)

  6. taivu commented on Mar 9, 2017

    @taivu

    I get the same error in MacOS El Capitan and Ubuntu (both node 7). Weird thing is that in Ubuntu it still runs and starts the server, but doesnt detect any changes to files. In MacOS, it just quits.

  7. Timer commented on Mar 9, 2017

    @Timer
    Contributor

    (We definitely should support Node 7 tho)

    We should probably run all test cases on Node 7 then. 🤷‍♀️

    Node 8 comes out in a month though, which I assume means we would drop Node 7 support. Worth waiting?

  8. gaearon commented on Mar 9, 2017

    @gaearon
    Contributor

    I don't think we should skip supported versions, it would be confusing.

  9. vhain commented on Mar 9, 2017

    @vhain

    It can be bug of Node 7.7.2 and if it is, it should be fixed by nodejs/node#11762

    +i think that promise should be catch somewhere

  10. Timer commented on Mar 9, 2017

    @Timer
    Contributor

    Ah, brilliant @vhain! This definitely looks like a regression then. 😄

  11. changed the title [-]UnhandledPromiseRejectionWarning in Windows 10[/-] [+]UnhandledPromiseRejectionWarning on Node 7.7.2[/+] on Mar 9, 2017
  12. whelmich commented on Mar 9, 2017

    @whelmich

    After upgrading detect-port in react-scripts to 1.1.0, I can run create-react-app without any issues on node 4.8.0, 6.10.0 and 7.7.2. So upgrading it could still be a solution, without impacting the minimal node version.

    Travis/tests failing on detect-port:1.1.0 with node <6 as mentioned earlier, seem to be related to its test dependency only. It doesn't withhold the package from working on node <6 when used with react-scripts. Though, I'm not sure if this may influence any other create-react-app tests somehow.

  13. gaearon commented on Mar 9, 2017

    @gaearon
    Contributor

    Want to send a PR enabling tests on Node 7 + bumping the version?

  14. 19 remaining items

  15. mnemanja commented on Mar 17, 2017

    @mnemanja

    @gaearon
    Thanks,
    removing node_modules completely and installing all the dependencies fixed the issue for me.

    Thanks for the hint @Timer, I'll be sure to remember it next time something like this happens.

    Keep up the good work guys :)

  16. gaearon commented on Mar 17, 2017

    @gaearon
    Contributor

    Looks like we need to bump detect-port to 1.1.1: node-modules/detect-port#16 (comment)

    PR, anyone?

  17. Andreyco commented on Mar 20, 2017

    @Andreyco
    Contributor

    cc @gaearon PR opened #1861
    Can confirm, detect-port picks next available port as expected.

  18. added a commit that references this issue on Apr 17, 2017
  19. taykcrane commented on Aug 21, 2017

    @taykcrane

    For any newbies running into this bug, I fixed it by downgrading NPM to the LTS (latest stable version) of 6.11.2.

  20. davidcalhoun commented on Dec 19, 2017

    @davidcalhoun

    Had a similar issue using npm to install. Fixed by removing both npm-modules and package-lock.json (a variant of @gaearon's comment above)

  21. shiziChing commented on Feb 7, 2018

    @shiziChing

    说中文撒大佬们

  22. locked and limited conversation to collaborators on Jan 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions