| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
When spawn() fails at the OS level (ENOENT, EACCES, EAGAIN, EMFILE, ENFILE), the resulting ChildProcess only ever emits 'error', never 'exit'. The `timeout` option's cleanup only listened for 'exit', so the timer stayed armed for the full `timeout` duration on any spawn-time failure, holding the event loop open well after the promise/callback had already settled via 'error'. Clear the timer on 'error' as well as 'exit'. Fixes: nodejs#65504 Signed-off-by: kishore280 <maheshwarankishore@gmail.com>
'close' fires after 'exit' or 'error', so one listener is enough. The old 'error' listener also had a side effect I didn't intend: it quietly stopped Node's 'Unhandled error event' crash for anyone using timeout without their own error handler. Not this fix's job. Signed-off-by: kishore280 <maheshwarankishore@gmail.com>
Sorry, something went wrong.
| @@ -0,0 +1,22 @@ | |||
| 'use strict'; | |||
|
|
|||
| // Measures the child's actual exit time, not just its 'error' event - the outer spawnSync timeout catches a leaked inner timer. | |||
There was a problem hiding this comment.
This line has a length of 128. Maximum allowed is 120.
| // Measures the child's actual exit time, not just its 'error' event - the outer spawnSync timeout catches a leaked inner timer. | |
| // Measures the child's actual exit time, not just its 'error' event. | |
| // The outer spawnSync timeout catches a leaked inner timer. |
Sorry, something went wrong.
| const bugStallMs = common.platformTimeout(10000); | ||
| const outerTimeoutMs = common.platformTimeout(2000); | ||
|
|
||
| const child = spawnSync(process.execPath, ['-e', ` |
There was a problem hiding this comment.
| const child = spawnSync(process.execPath, ['-e', ` | |
| spawnSyncAndExitWithoutError(process.execPath, ['-e', ` |
Sorry, something went wrong.
Signed-off-by: kishore280 <maheshwarankishore@gmail.com>
Codecov Report✅ All modified and coverable lines are covered by tests. @@ Coverage Diff @@
## main #65506 +/- ##
==========================================
+ Coverage 90.14% 90.16% +0.02%
==========================================
Files 751 751
Lines 252697 253586 +889
Branches 47557 47772 +215
==========================================
+ Hits 227788 228648 +860
- Misses 16181 16200 +19
- Partials 8728 8738 +10
... and 50 files with indirect coverage changes 🚀 New features to boost your workflow:
|
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
timeout's only cleanup was child.once('exit', clearTimeout). A spawn-time failure (ENOENT etc.) only emits error, never exit, so the timer stayed armed for the full timeout duration. Clear it on error too.
Checked: doesn't double-fire or race with the timeout's own kill-failure path (try { child.kill() } catch { child.emit('error') }). That emit('error') runs synchronously before the timeout callback's own timeoutId = null, so clearSpawnTimeout sees the already-fired timer id and calls clearTimeout on it - a documented no-op. The callback's own null-assignment right after is then redundant but harmless.
Fixes: #65504