| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 272ddb1 commit 1805236
4 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1810,20 +1810,6 @@ An attempt was made to load a module with an unknown or unsupported format. | |||
| 1810 | 1810 | An invalid or unknown process signal was passed to an API expecting a valid | |
| 1811 | 1811 | signal (such as [`subprocess.kill()`][]). | |
| 1812 | 1812 | ||
| 1813 | - <a id="ERR_UNKNOWN_STDIN_TYPE"></a> | ||
| 1814 | - ### ERR_UNKNOWN_STDIN_TYPE | ||
| 1815 | - | ||
| 1816 | - An attempt was made to launch a Node.js process with an unknown `stdin` file | ||
| 1817 | - type. This error is usually an indication of a bug within Node.js itself, | ||
| 1818 | - although it is possible for user code to trigger it. | ||
| 1819 | - | ||
| 1820 | - <a id="ERR_UNKNOWN_STREAM_TYPE"></a> | ||
| 1821 | - ### ERR_UNKNOWN_STREAM_TYPE | ||
| 1822 | - | ||
| 1823 | - An attempt was made to launch a Node.js process with an unknown `stdout` or | ||
| 1824 | - `stderr` file type. This error is usually an indication of a bug within Node.js | ||
| 1825 | - itself, although it is possible for user code to trigger it. | ||
| 1826 | - | ||
| 1827 | 1813 | <a id="ERR_V8BREAKITERATOR"></a> | |
| 1828 | 1814 | ### ERR_V8BREAKITERATOR | |
| 1829 | 1815 | ||
@@ -2080,6 +2066,28 @@ kind of internal Node.js error that should not typically be triggered by user | |||
| 2080 | 2066 | code. Instances of this error point to an internal bug within the Node.js | |
| 2081 | 2067 | binary itself. | |
| 2082 | 2068 | ||
| 2069 | + <a id="ERR_UNKNOWN_STDIN_TYPE"></a> | ||
| 2070 | + ### ERR_UNKNOWN_STDIN_TYPE | ||
| 2071 | + <!-- YAML | ||
| 2072 | + added: v8.0.0 | ||
| 2073 | + removed: REPLACEME | ||
| 2074 | + --> | ||
| 2075 | + | ||
| 2076 | + An attempt was made to launch a Node.js process with an unknown `stdin` file | ||
| 2077 | + type. This error is usually an indication of a bug within Node.js itself, | ||
| 2078 | + although it is possible for user code to trigger it. | ||
| 2079 | + | ||
| 2080 | + <a id="ERR_UNKNOWN_STREAM_TYPE"></a> | ||
| 2081 | + ### ERR_UNKNOWN_STREAM_TYPE | ||
| 2082 | + <!-- YAML | ||
| 2083 | + added: v8.0.0 | ||
| 2084 | + removed: REPLACEME | ||
| 2085 | + --> | ||
| 2086 | + | ||
| 2087 | + An attempt was made to launch a Node.js process with an unknown `stdout` or | ||
| 2088 | + `stderr` file type. This error is usually an indication of a bug within Node.js | ||
| 2089 | + itself, although it is possible for user code to trigger it. | ||
| 2090 | + | ||
| 2083 | 2091 | <a id="ERR_VALUE_OUT_OF_RANGE"></a> | |
| 2084 | 2092 | ### ERR_VALUE_OUT_OF_RANGE | |
| 2085 | 2093 | <!-- YAML | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -947,10 +947,7 @@ E('ERR_UNKNOWN_ENCODING', 'Unknown encoding: %s', TypeError); | |||
| 947 | 947 | E('ERR_UNKNOWN_FILE_EXTENSION', 'Unknown file extension: %s', Error); | |
| 948 | 948 | E('ERR_UNKNOWN_MODULE_FORMAT', 'Unknown module format: %s', RangeError); | |
| 949 | 949 | E('ERR_UNKNOWN_SIGNAL', 'Unknown signal: %s', TypeError); | |
| 950 | - E('ERR_UNKNOWN_STDIN_TYPE', 'Unknown stdin file type', Error); | ||
| 951 | 950 | ||
| 952 | - // This should probably be a `TypeError`. | ||
| 953 | - E('ERR_UNKNOWN_STREAM_TYPE', 'Unknown stream file type', Error); | ||
| 954 | 951 | E('ERR_V8BREAKITERATOR', | |
| 955 | 952 | 'Full ICU data not installed. See https://github.com/nodejs/node/wiki/Intl', | |
| 956 | 953 | Error); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,10 +1,5 @@ | |||
| 1 | 1 | 'use strict'; | |
| 2 | 2 | ||
| 3 | - const { | ||
| 4 | - ERR_UNKNOWN_STDIN_TYPE, | ||
| 5 | - ERR_UNKNOWN_STREAM_TYPE | ||
| 6 | - } = require('internal/errors').codes; | ||
| 7 | - | ||
| 8 | 3 | exports.setupProcessStdio = setupProcessStdio; | |
| 9 | 4 | exports.getMainThreadStdio = getMainThreadStdio; | |
| 10 | 5 | ||
@@ -87,8 +82,11 @@ function getMainThreadStdio() { | |||
| 87 | 82 | break; | |
| 88 | 83 | ||
| 89 | 84 | default: | |
| 90 | - // Probably an error on in uv_guess_handle() | ||
| 91 | - throw new ERR_UNKNOWN_STDIN_TYPE(); | ||
| 85 | + // Provide a dummy contentless input for e.g. non-console | ||
| 86 | + // Windows applications. | ||
| 87 | + const { Readable } = require('stream'); | ||
| 88 | + stdin = new Readable({ read() {} }); | ||
| 89 | + stdin.push(null); | ||
| 92 | 90 | } | |
| 93 | 91 | ||
| 94 | 92 | // For supporting legacy API we put the FD here. | |
@@ -123,6 +121,12 @@ function getMainThreadStdio() { | |||
| 123 | 121 | return stdin; | |
| 124 | 122 | } | |
| 125 | 123 | ||
| 124 | + exports.resetStdioForTesting = function() { | ||
| 125 | + stdin = undefined; | ||
| 126 | + stdout = undefined; | ||
| 127 | + stderr = undefined; | ||
| 128 | + }; | ||
| 129 | + | ||
| 126 | 130 | return { | |
| 127 | 131 | getStdout, | |
| 128 | 132 | getStderr, | |
@@ -199,8 +203,14 @@ function createWritableStdioStream(fd) { | |||
| 199 | 203 | break; | |
| 200 | 204 | ||
| 201 | 205 | default: | |
| 202 | - // Probably an error on in uv_guess_handle() | ||
| 203 | - throw new ERR_UNKNOWN_STREAM_TYPE(); | ||
| 206 | + // Provide a dummy black-hole output for e.g. non-console | ||
| 207 | + // Windows applications. | ||
| 208 | + const { Writable } = require('stream'); | ||
| 209 | + stream = new Writable({ | ||
| 210 | + write(buf, enc, cb) { | ||
| 211 | + cb(); | ||
| 212 | + } | ||
| 213 | + }); | ||
| 204 | 214 | } | |
| 205 | 215 | ||
| 206 | 216 | // For supporting legacy API we put the FD here. | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,27 @@ | |||
| 1 | + 'use strict'; | ||
| 2 | + const common = require('../common'); | ||
| 3 | + const assert = require('assert'); | ||
| 4 | + const child_process = require('child_process'); | ||
| 5 | + | ||
| 6 | + if (common.isWindows) | ||
| 7 | + common.skip('fs.closeSync(n) does not close stdio on Windows'); | ||
| 8 | + | ||
| 9 | + function runTest(fd, streamName, testOutputStream, expectedName) { | ||
| 10 | + const result = child_process.spawnSync(process.execPath, [ | ||
| 11 | + '--expose-internals', | ||
| 12 | + '-e', ` | ||
| 13 | + require('internal/process/stdio').resetStdioForTesting(); | ||
| 14 | + fs.closeSync(${fd}); | ||
| 15 | + const ctorName = process.${streamName}.constructor.name; | ||
| 16 | + process.${testOutputStream}.write(ctorName); | ||
| 17 | + `]); | ||
| 18 | + assert.strictEqual(result[testOutputStream].toString(), expectedName, | ||
| 19 | + `stdout:\n${result.stdout}\nstderr:\n${result.stderr}\n` + | ||
| 20 | + `while running test with fd = ${fd}`); | ||
| 21 | + if (testOutputStream !== 'stderr') | ||
| 22 | + assert.strictEqual(result.stderr.toString(), ''); | ||
| 23 | + } | ||
| 24 | + | ||
| 25 | + runTest(0, 'stdin', 'stdout', 'Readable'); | ||
| 26 | + runTest(1, 'stdout', 'stderr', 'Writable'); | ||
| 27 | + runTest(2, 'stderr', 'stdout', 'Writable'); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments