node icon indicating copy to clipboard operation
node copied to clipboard

EINVAL errors (events.js:160) with Node 7.1.0 on Windows 10

Open mischah opened this issue 10 years ago β€’ 69 comments

  • Version: 7.1.0
  • Platform: Windows 10
  • Subsystem: Events

Hej there,

several users have problems with different packages running node 7.1.0 on Windows 10:

  • https://github.com/mochajs/mocha/issues/2577
  • https://github.com/facebook/react-native/issues/10824
  • https://github.com/electron/electron/issues/7919
  • https://github.com/yeoman/yo/issues/485
  • https://github.com/yeoman/yo/issues/486

All of them seem to have the following in common:

  • It used to work with node 7.0.0 and stopped working with 7.1.0
  • A similiar error with different stacktrace:
events.js:160
      throw er; // Unhandled 'error' event

Error: write EINVAL

Could you enlighten us? Is it a regression in Node.js?

Thanks, Michael

mischah avatar Nov 10 '16 11:11 mischah

It's possible the libuv upgrade introduced a regression, I don't see anything else that is an obvious culprit. What happens when you revert commit 106d719?

bnoordhuis avatar Nov 10 '16 12:11 bnoordhuis

For me it broke between 7.0.0 and 7.1.0 spawning webpack-dev-server in a child process. Related: #9534

killroy42 avatar Nov 10 '16 14:11 killroy42

What happens when you revert commit 106d719?

I can’t reproduce the errors right now (wrong OS).

But if someone else can, how could they check if this helps? Am I right with the following steps?

  1. Clone nodejs/node
  2. Checkout branch v7.1.0-proposal
  3. Revert commit 106d719
  4. Build node source for Windows
    • See: https://github.com/nodejs/node/blob/master/BUILDING.md#windows
  5. Try to reproduce the error

mischah avatar Nov 10 '16 14:11 mischah

We have the same problem in Windows 10 x64

skcc75 avatar Nov 10 '16 14:11 skcc75

I'm new to React Native, and have encountered the same problem. Just did a fresh install, and downloaded the Awesome Project (Android), following the instructions on https://facebook.github.io/react-native/docs/getting-started.html

I'm running Windows 10, x64

Error message C:\Users\Edwin\AwesomeProject>react-native run-android events.js:160 throw er; // Unhandled 'error' event ^

Error: write EINVAL at exports._errnoException (util.js:1022:11) at WriteStream.Socket._writeGeneric (net.js:715:26) at WriteStream.Socket._write (net.js:734:8) at doWrite (_stream_writable.js:334:12) at writeOrBuffer (_stream_writable.js:320:5) at WriteStream.Writable.write (_stream_writable.js:247:11) at WriteStream.Socket.write (net.js:661:40) at WriteStream.stream.write (C:\Users\Edwin\AwesomeProject\node_modules\ansi\lib\newlines.js:36:21) at Object.execFileSync (child_process.js:506:20) at Object.run (C:/Users/Edwin/AwesomeProject/node_modules/react-native/local-cli/cliEntry.js:157:16)

EdwinChua avatar Nov 10 '16 15:11 EdwinChua

@bnoordhuis @mischah Rolling back 106d719 solves the problem for us with webpack-dev-server. Also solves the problem with mocha https://github.com/mochajs/mocha/issues/2577

skcc75 avatar Nov 10 '16 15:11 skcc75

npm-windows-upgrade here, we have the same issue.

felixrieseberg avatar Nov 10 '16 16:11 felixrieseberg

Here is our Win10 x64 build of Node.js master (7.1.1-pre) sans 106d719 to test:

  • 7z of Release folder: (link deleted) (69.8MB)
  • 7z of node.exe: (link deleted) (4.2MB)

P.S. See https://github.com/nodejs/node/issues/9542#issuecomment-259958895 for updated build and link

skcc75 avatar Nov 10 '16 16:11 skcc75

I tried your test build, and while I didn't rebuild all my binaries and thus cannot run all my services with it, it does start up webpack-dev-server without issue and appears to run.

killroy42 avatar Nov 10 '16 16:11 killroy42

Can someone try this patch? https://github.com/libuv/libuv/pull/889 is currently my prime suspect, seeing how all the bug reports are for Windows 10.

diff --git a/deps/uv/src/win/tty.c b/deps/uv/src/win/tty.c
index 18d68d0..88b8ef9 100644
--- a/deps/uv/src/win/tty.c
+++ b/deps/uv/src/win/tty.c
@@ -134,7 +134,7 @@ typedef enum {
   UV_UNSUPPORTED
 } uv_vtermstate_t;
 /* Determine whether or not ANSI support is enabled. */
-static uv_vtermstate_t uv__vterm_state = UV_UNCHECKED;
+static uv_vtermstate_t uv__vterm_state = UV_UNSUPPORTED;
 static void uv__determine_vterm_state(HANDLE handle);

 void uv_console_init() {

cc @nodejs/platform-windows

bnoordhuis avatar Nov 10 '16 21:11 bnoordhuis

@bnoordhuis Fixes mocha for me.

seishun avatar Nov 10 '16 22:11 seishun

I also had issues with weird color in my console, such as black text on black background. Makes sense as your patch is referencing ANSI support.

killroy42 avatar Nov 10 '16 23:11 killroy42

/cc @iWuzHere

santigimeno avatar Nov 10 '16 23:11 santigimeno

Issue also shows up while installing windows-build-tools and running the angular-cli

manwaring avatar Nov 11 '16 03:11 manwaring

@joaocgreis @bzoz can you take a look?

/cc @digitalinfinity

joshgav avatar Nov 11 '16 05:11 joshgav

@bnoordhuis

libuv/libuv#889 is currently my prime suspect, seeing how all the bug reports are for Windows 10.

@miniksa can you take a look at libuv/libuv#889 too?

joshgav avatar Nov 11 '16 05:11 joshgav

I was also having this error and reverted to node's stable version 6.9.* and it worked.

topgun743 avatar Nov 11 '16 07:11 topgun743

@bnoordhuis https://github.com/nodejs/node/issues/9542#issuecomment-259813312 patch applied to v7.1.0 source fixes the problem with webpack-dev-server and mocha for 64-bit build on Windows 10.

Here is the patched node.exe 64-bit Windows executable, built with vcbuild release nosign x64 for others to verify:

https://mega.nz/#!eRMxwCaY!Jo0aulbo-Nm0OLMAcx1pfnVdWnCXiTocBju1aA66elI

skcc75 avatar Nov 11 '16 13:11 skcc75

Seems like my change broke stuff 😒 Created https://github.com/libuv/libuv/issues/1135

imran-iq avatar Nov 11 '16 17:11 imran-iq

BTW, since it involves tty and ANSI codes, is this likely the cause of my issues with black-on-black colors in the console for part of the output and after the process died?

(PS: "color 07" in windows resets colors it if you struggle with this)

killroy42 avatar Nov 11 '16 17:11 killroy42