node icon indicating copy to clipboard operation
node copied to clipboard

bootstrap: try-catch around potentially failing stream.write() for `node --help`

Open jcbhmr opened this issue 1 year ago • 2 comments

fixes #51448

jcbhmr avatar Jan 14 '24 03:01 jcbhmr

how would i go about adding a test? 😵 the 'message' and 'pseudo-tty' folders dont seem to support node --help | head -n1 piping... do they? am i missing something obvious (probably)

jcbhmr avatar Jan 20 '24 01:01 jcbhmr

In https://github.com/nodejs/node/issues/51448#issuecomment-1890829515 it was mentioned that console.log() can swallow the error too (by default, console.log() swallows all errors except stack overflow). I'd prefer that instead of special casing EPIPE since the purpose is similar (only stack overflow errors should be rethrown).

joyeecheung avatar Feb 05 '24 13:02 joyeecheung

CI: https://ci.nodejs.org/job/node-test-pull-request/57352/

nodejs-github-bot avatar Feb 23 '24 16:02 nodejs-github-bot

CI: https://ci.nodejs.org/job/node-test-pull-request/57533/

nodejs-github-bot avatar Mar 01 '24 15:03 nodejs-github-bot

ci failures extracted for reading convenience:

https://ci.nodejs.org/job/node-test-commit-linux-containered/nodes=ubuntu2204_sharedlibs_shared_x64/41902/console

09:58:52 not ok 4088 sequential/test-watch-mode-inspect # TODO : Fix flaky test
09:58:52   ---
09:58:52   duration_ms: 120028.02600
09:58:52   severity: fail
09:58:52   exitcode: -15
09:58:52   stack: |-
09:58:52     timeout
09:58:52     [test] Connecting to a child Node process
09:58:52     [test] Testing /json/list
09:58:52     TAP version 13
09:58:52     [err] (node:2857497) ExperimentalWarning: Watch mode is an experimental feature and might change at any time
09:58:52     [err] (Use `node --trace-warnings ...` to show where the warning was created)
09:58:52     [err] 
09:58:52     [err] Debugger listening on ws://127.0.0.1:39547/16cc9a88-02fe-47c2-a281-bc30b249b35d
09:58:52     [err] 
09:58:52     [err] For help, see: https://nodejs.org/en/docs/inspector
09:58:52     [err] 
09:58:52     [err] Debugger attached.
09:58:52     [err] 
09:58:52     [test] Connecting to a child Node process
09:58:52     [test] Testing /json/list
09:58:52     [err] Debugger ending on ws://127.0.0.1:39547/16cc9a88-02fe-47c2-a281-bc30b249b35d
09:58:52     [err] For help, see: https://nodejs.org/en/docs/inspector
09:58:52     [err] 
09:58:52     [out] safe to debug now
09:58:52     [out] 

https://ci.nodejs.org/job/node-test-commit-linuxone/nodes=rhel8-s390x/42487/console

not ok 3744 pummel/test-net-pause
09:26:43   ---
09:26:43   duration_ms: 813.53300
09:26:43   severity: fail
09:26:43   exitcode: 1
09:26:43   stack: |-
09:26:43     pause at: 0
09:26:43     node:assert:126
09:26:43       throw new AssertionError(obj);
09:26:43       ^
09:26:43     
09:26:43     AssertionError [ERR_ASSERTION]: Expected values to be strictly equal:
09:26:43     
09:26:43     false !== true
09:26:43     
09:26:43         at Timeout._onTimeout (/home/iojs/build/workspace/node-test-commit-linuxone/test/pummel/test-net-pause.js:56:12)
09:26:43         at listOnTimeout (node:internal/timers:573:17)
09:26:43         at process.processTimers (node:internal/timers:514:7) {
09:26:43       generatedMessage: true,
09:26:43       code: 'ERR_ASSERTION',
09:26:43       actual: false,
09:26:43       expected: true,
09:26:43       operator: 'strictEqual'
09:26:43     }
09:26:43     
09:26:43     Node.js v22.0.0-pre

jcbhmr avatar Mar 01 '24 16:03 jcbhmr

i think i fixed ci failures. now uses console.log(). require()-ed after the bootstrap() function.

do i still need a test? how would i even go about adding such a test? 😵

jcbhmr avatar Mar 05 '24 17:03 jcbhmr

CI: https://ci.nodejs.org/job/node-test-pull-request/57595/

nodejs-github-bot avatar Mar 05 '24 18:03 nodejs-github-bot

About how this can be reproduced - one possible solution is, create a TCP socket, call end() on it on this end, pass it as your stdout to a spawned child process, which does node --help. (not 100% sure here, some additional coordination might be necessary, but the idea of using an ended TCP socket should be valid).

joyeecheung avatar Mar 05 '24 18:03 joyeecheung

i added a test that i think works. it CORRECTLY FAILS on my installed node v21.7.1.

jcbhmr avatar Mar 09 '24 00:03 jcbhmr

CI: https://ci.nodejs.org/job/node-test-pull-request/59114/

nodejs-github-bot avatar May 11 '24 15:05 nodejs-github-bot

CI: https://ci.nodejs.org/job/node-test-pull-request/59179/

nodejs-github-bot avatar May 12 '24 17:05 nodejs-github-bot

CI: https://ci.nodejs.org/job/node-test-pull-request/59186/

nodejs-github-bot avatar May 12 '24 19:05 nodejs-github-bot

CI: https://ci.nodejs.org/job/node-test-pull-request/59189/

nodejs-github-bot avatar May 12 '24 19:05 nodejs-github-bot

Landed in c7d53f0169aba592d61b1f2d13c39e5dd4817c7e

aduh95 avatar May 12 '24 19:05 aduh95