Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

--use-legacy and process redirection are broken on Windows #1844

Closed
Corion opened this issue Oct 8, 2011 · 2 comments
Closed

--use-legacy and process redirection are broken on Windows #1844

Corion opened this issue Oct 8, 2011 · 2 comments
Labels

Comments

@Corion
Copy link

Corion commented Oct 8, 2011

In nodejs 0.5.8 (Windows 32-bit build), the following immediately crashes:

> nodejs-versions\nodejs-0.5.8\node.exe --use-legacy -e console.log('OK')

node.js:238
          stdout._handle.unref();
                         ^
TypeError: Cannot call method 'unref' of undefined
    at EventEmitter.stdout (node.js:238:26)
    at Object.<anonymous> (console.js:26:10)
    at Object.<anonymous> (eval at <anonymous> (eval:1:75))
    at Object.<anonymous> (eval:1:63)
    at Module._compile (module.js:432:26)
    at startup (node.js:96:14)
    at node.js:559:3

In version 0.5.7, the command worked as expected:

> nodejs-versions\nodejs-0.5.7\node.exe --use-legacy -e console.log('OK')
OK

It seems as if STDIO is broken on Windows. This is problematic as it seems that nodejs also uses this "legacy" mode when it is launched from within another program with its standard IO redirected to other file handles. This works with 0.5.7:

>nodejs-versions\nodejs-0.5.7\node.exe -e console.log('OK') |perl -ple "s!$! piped to $^X!"
OK piped to C:\strawberry\perl\bin\perl.exe

... but fails fatally with 0.5.8, without any recourse to launch nodejs as subprocess and receive data from it:

>nodejs-versions\nodejs-0.5.8\node.exe -e console.log('OK') |perl -ple "s!$! piped to $^X!"

node.js:207
        throw e; // process.nextTick error, or 'error' event on first tick
              ^
Error: write EINVAL
    at errnoException (net_uv.js:566:11)
    at Socket.write (net_uv.js:389:18)
    at Object.<anonymous> (console.js:26:18)
    at Object.<anonymous> (eval at <anonymous> (eval:1:75))
    at Object.<anonymous> (eval:1:63)
    at Module._compile (module.js:432:26)
    at startup (node.js:96:14)
    at node.js:559:3

@koichik
Copy link

koichik commented Oct 9, 2011

Linux is the same. The cause is #1726 (7e62bc9).

@bnoordhuis
Copy link
Member

Thanks, should be fixed in 326ba25.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants