nodejs / node

Node.js JavaScript runtime ✨🐢🚀✨
https://nodejs.org
Other
107.86k stars 29.72k forks source link

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

Closed mischah closed 8 years ago

mischah commented 8 years ago

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:

Error: write EINVAL



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

Thanks, Michael
not-an-aardvark commented 8 years ago

ESLint received a bug report from @danZib a few days ago that seems to also be related to the libuv upgrade (windows-only IO failure on Node 7). I'll add it to this issue in case it's related.

Error message:
events.js:160
throw er; // Unhandled 'error' event
^
Error: This socket is closed
at WriteStream.Socket._writeGeneric (net.js:683:19)
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 Console.log (console.js:43:16)
at process.once.err (C:\Users\Daniel\AppData\Roaming\npm\node_modules\eslint\bin\eslint.js:50:17)
at process.g (events.js:292:16)
at emitOne (events.js:96:13)

It apparently happens on a console.log call when this code is run. It only fails on windows, and only with Node 7. (I didn't encounter the issue myself, so I'm unable to verify whether libuv 1.10.1 fixes the issue.)

killroy42 commented 8 years ago

In which version will this rollback land? 7.1.1?

cjihrig commented 8 years ago

There is a Node v7 release tentatively scheduled for this coming Tuesday. I believe it will be 7.1.1. If any semver minor commits are included, it will be 7.2.0.

AbrantesMar commented 7 years ago

Hello, on my windows 10, I uninstalled node v 7.1.0 and reinstalled 6.9.1, and it worked normally ...

The error was:

Error: This socket is closed at WriteStream.Socket._writeGeneric (net.js:683:19) 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\m.nunes.abrantes\Documents\Projeto\react_ative\testereact\node_modules\ansi\lib\newlines.js:36:21) at Console.warn (console.js:51:16) at process.on (internal/process/warning.js:21:17) at emitOne (events.js:96:13)

seanzer commented 7 years ago

I'm pretty sure it's fixed in the nightlies, or wait for 7.1.1

tonydearaujo commented 7 years ago

@seanzer, 7.1.1 nightly was release on Nov 9th. That did not fix the problem. I'm waiting for a new release which is supposed to happen tonight. @AbrantesMar, 7.0.0 works fine as well.

tonydearaujo commented 7 years ago

Feedback: Node 7.2.0, released last night, has solved my problem, which was serving Angular CLI projects on Windows 10. Thank you!

erwinjulius commented 7 years ago

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

santigimeno commented 7 years ago

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: https://github.com/libuv/libuv/pull/1143. Thanks in advance. /cc @kyrylkov

kyrylkov commented 7 years ago

@santigimeno So current Node v7.2.0 or v7.x branch plus libuv with https://github.com/libuv/libuv/pull/1143 ?

santigimeno commented 7 years ago

@kyrylkov yes. Thanks!

kyrylkov commented 7 years ago

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

santigimeno commented 7 years ago

@kyrylkov thanks for the feedback!

mcianc commented 7 years ago

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

pavelkornev commented 7 years ago

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

2) 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 commented 7 years ago

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)
ulou commented 7 years ago

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

thasmo commented 6 years ago

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 npm@5.6.0
3 info using node@v9.5.0
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 commented 4 years ago

Downgarding node version worked for me