Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
mischah opened this issue Nov 10, 2016 · 69 comments
Closed

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

mischah opened this issue Nov 10, 2016 · 69 comments
Labels
libuv Issues and PRs related to the libuv dependency or the uv binding. windows Issues and PRs related to the Windows platform.

Comments

@mischah
Copy link

mischah commented Nov 10, 2016

  • 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:

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

@bnoordhuis
Copy link
Member

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 bnoordhuis added v7.x windows Issues and PRs related to the Windows platform. labels Nov 10, 2016
@killroy42
Copy link

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

@mischah
Copy link
Author

mischah commented Nov 10, 2016

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
  5. Try to reproduce the error

@kyrylkov
Copy link

We have the same problem in Windows 10 x64

@EdwinChua
Copy link

EdwinChua commented Nov 10, 2016

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)

@kyrylkov
Copy link

kyrylkov commented Nov 10, 2016

@bnoordhuis @mischah Rolling back 106d719 solves the problem for us with webpack-dev-server. Also solves the problem with mocha mochajs/mocha#2577

@felixrieseberg
Copy link
Member

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

@kyrylkov
Copy link

kyrylkov commented Nov 10, 2016

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 #9542 (comment) for updated build and link

@killroy42
Copy link

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.

@Trott Trott added the libuv Issues and PRs related to the libuv dependency or the uv binding. label Nov 10, 2016
@bnoordhuis
Copy link
Member

Can someone try this patch? libuv/libuv#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

@seishun
Copy link
Contributor

seishun commented Nov 10, 2016

@bnoordhuis
Fixes mocha for me.

@killroy42
Copy link

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.

@santigimeno
Copy link
Member

/cc @iwuzhere

@manwaring
Copy link

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

@joshgav
Copy link
Contributor

joshgav commented Nov 11, 2016

@joaocgreis @bzoz can you take a look?

/cc @digitalinfinity

@joshgav
Copy link
Contributor

joshgav commented Nov 11, 2016

@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?

@topgun743
Copy link

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

@kyrylkov
Copy link

kyrylkov commented Nov 11, 2016

@bnoordhuis #9542 (comment) 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

@erwinjulius
Copy link

Node 7.2 also resolved my problem with react-native run-android on Win10

@santigimeno
Copy link
Member

We're trying to bring back to libuv the functionality that caused this regression (with fixes, of course). Before merging it, it would be great if someone could confirm that it does not cause any problems. The PR in question is: libuv/libuv#1143. Thanks in advance.
/cc @kyrylkov

@kyrylkov
Copy link

kyrylkov commented Nov 28, 2016

@santigimeno So current Node v7.2.0 or v7.x branch plus libuv with libuv/libuv#1143 ?

@santigimeno
Copy link
Member

@kyrylkov yes. Thanks!

@kyrylkov
Copy link

kyrylkov commented Nov 28, 2016

@santigimeno Win64 Node.js v7.2.1-pre built with libuv/libuv#1143 works fine with our webpack /webpack-dev-server config and mocha tests.

@santigimeno
Copy link
Member

@kyrylkov thanks for the feedback!

@mcianc
Copy link

mcianc commented Dec 14, 2016

I update node from 7.1.0 to 7.2.1 .. and solved the problem

@pavelkornev
Copy link

We still have a problem on Windows 10 (x64) when trying to "spawn" a child process with ESLint. We have tried 2 NodeJS versions:

  1. node-v6.9.5-x64:
C:\Users\pavelkornev\workspace\testproject\node_modules\.bin\eslint src
events.js:160
      throw er; // Unhandled 'error' event
      ^

Error: spawn C:\Users\pavelkornev\workspace\testproject\node_modules\.bin\eslint ENOENT
    at exports._errnoException (util.js:1022:11)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:193:32)
    at onErrorNT (internal/child_process.js:359:16)
    at _combinedTickCallback (internal/process/next_tick.js:74:11)
    at process._tickCallback (internal/process/next_tick.js:98:9)
    at Module.runMain (module.js:606:11)
    at run (bootstrap_node.js:394:7)
    at startup (bootstrap_node.js:149:9)
    at bootstrap_node.js:509:3
  1. node-v7.5.0-x64:
C:\Users\pavelkornev\workspace\testproject\node_modules\.bin\eslint src
events.js:161
      throw er; // Unhandled 'error' event
      ^

Error: spawn C:\Users\pavelkornev\workspace\testproject\node_modules\.bin\eslint ENOENT
    at exports._errnoException (util.js:1023:11)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:193:32)
    at onErrorNT (internal/child_process.js:359:16)
    at _combinedTickCallback (internal/process/next_tick.js:74:11)
    at process._tickCallback (internal/process/next_tick.js:98:9)
    at Module.runMain (module.js:607:11)
    at run (bootstrap_node.js:418:7)
    at startup (bootstrap_node.js:139:9)
    at bootstrap_node.js:533:3

Test script: test.js

const fs = require('fs');
const { spawn } = require('child_process');
const ESLINT_PATH = path.resolve(__dirname, './node_modules/.bin/eslint');

spawn(ESLINT_PATH, ["src"]);

We are using ESLint 1.10.3 - yes, it's quite old version but it works just fine without "spawn" call on both NodeJS versions above. By some reasons in our build script we need to run ESLint as child process, on the OSX there are no such problems, the issue is reproducible only on windows machines.

Does anyone know how we can handle it?

@Mac-lp3
Copy link

Mac-lp3 commented Apr 4, 2017

Hi,

I am still experiencing the EINVAL issues. Is there a work around for this?

OS: Windows 7
Node: v7.8.0x64
Standard command prompt

Code:

'use strict'

const readline = require('readline')

let uid = ''

const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout // note, it does not throw the exception if i remove the output
})

rl.question('Enter database Username: ', (name) => {
  uid = name
  rl.close()
})

Error:

Enter database Username: events.js:163
      throw er; // Unhandled 'error' event
      ^

Error: read EINVAL
    at exports._errnoException (util.js:1034:11)
    at TTY.onread (net.js:580:26)

MylesBorins pushed a commit that referenced this issue May 16, 2017
Fixes: #9542
Fixes: #9546
PR-URL: #9647
Reviewed-By: Imran Iqbal <[email protected]>
Reviewed-By: Santiago Gimeno <[email protected]>
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: Myles Borins <[email protected]>
Reviewed-By: Johan Bergström <[email protected]>
MylesBorins pushed a commit that referenced this issue May 18, 2017
Fixes: #9542
Fixes: #9546
PR-URL: #9647
Reviewed-By: Imran Iqbal <[email protected]>
Reviewed-By: Santiago Gimeno <[email protected]>
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: Myles Borins <[email protected]>
Reviewed-By: Johan Bergström <[email protected]>
@ulou
Copy link

ulou commented May 24, 2017

Installing LTS node version and reinstaling vue-cli solved problem.

andrew749 pushed a commit to michielbaird/node that referenced this issue Jul 19, 2017
Fixes: nodejs/node#9542
Fixes: nodejs/node#9546
PR-URL: nodejs/node#9647
Reviewed-By: Imran Iqbal <[email protected]>
Reviewed-By: Santiago Gimeno <[email protected]>
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: Myles Borins <[email protected]>
Reviewed-By: Johan Bergström <[email protected]>
@thasmo
Copy link

thasmo commented Feb 17, 2018

I'm experiencing this with node 9.5.0.

0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli   'C:\\Users\\user\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli   'start' ]
2 info using [email protected]
3 info using [email protected]
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info lifecycle @~prestart: @
6 info lifecycle @~start: @
7 verbose lifecycle @~start: unsafe-perm in lifecycle true
8 verbose lifecycle @~start: PATH: C:\Users\user\AppData\Roaming\npm\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;P:\PROJECT\node_modules\.bin;C:\Python27\;C:\Python27\Scripts;C:\Program Files\Docker\Docker\Resources\bin;C:\ProgramData\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Git\bin;C:\Program Files (x86)\Skype\Phone\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\ProgramData\ComposerSetup\bin;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files (x86)\HashiCorp\Vagrant\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files\Go\bin;C:\Program Files\nodejs\;C:\Program Files (x86)\Yarn\bin;C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\;C:\Users\user\Dropbox\Development\PHP\interpreter\7.1;C:\Users\user\AppData\Local\Microsoft\WindowsApps;C:\Users\user\AppData\Roaming\Composer\vendor\bin;C:\Users\user\go\bin;C:\Users\user\AppData\Local\.meteor\;C:\Users\user\AppData\Roaming\npm;C:\Users\user\AppData\Local\Yarn\bin
9 verbose lifecycle @~start: CWD: P:\PROJECT
10 silly lifecycle @~start: Args: [ '/d /s /c', 'ts-node webpack.server.ts' ]
11 silly lifecycle @~start: Returned: code: 1  signal: null
12 info lifecycle @~start: Failed to exec start script
13 verbose stack Error: @ start: `ts-node webpack.server.ts`
13 verbose stack Exit status 1
13 verbose stack     at EventEmitter.<anonymous> (C:\Users\user\AppData\Roaming\npm\node_modules\npm\node_modules\npm-lifecycle\index.js:285:16)
13 verbose stack     at EventEmitter.emit (events.js:160:13)
13 verbose stack     at ChildProcess.<anonymous> (C:\Users\user\AppData\Roaming\npm\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
13 verbose stack     at ChildProcess.emit (events.js:160:13)
13 verbose stack     at maybeClose (internal/child_process.js:943:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:220:5)
14 verbose pkgid @
15 verbose cwd P:\PROJECT
16 verbose Windows_NT 10.0.16299
17 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\user\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "start"
18 verbose node v9.5.0
19 verbose npm  v5.6.0
20 error code ELIFECYCLE
21 error errno 1
22 error @ start: `ts-node webpack.server.ts`
22 error Exit status 1
23 error Failed at the @ start script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]

@Nabila-Rafi
Copy link

Downgarding node version worked for me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
libuv Issues and PRs related to the libuv dependency or the uv binding. windows Issues and PRs related to the Windows platform.
Projects
None yet
Development

No branches or pull requests