Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error.stack is not updated when childProcess.destroy(error) is called (due to Node.js bug) #813

Closed
ehmicky opened this issue Feb 12, 2024 · 0 comments · Fixed by #814
Closed

Comments

@ehmicky
Copy link
Collaborator

ehmicky commented Feb 12, 2024

When childProcess.destroy(error) is called, the error rejected by Execa has a correct message, but not a correct stack.

The following works well:

const childProcess = execa('echo', {reject: false})
childProcess.stdout.destroy()
const {message, stack} = await childProcess
console.log('MESSAGE')
console.log(message)
console.log('\nSTACK')
console.log(stack)
MESSAGE
Command failed with ERR_STREAM_PREMATURE_CLOSE: echo
Premature close

STACK
Error [ERR_STREAM_PREMATURE_CLOSE]: Command failed with ERR_STREAM_PREMATURE_CLOSE: echo
Premature close
    at Socket.onclose (node:internal/streams/end-of-stream:154:30)
    at Socket.emit (node:events:527:35)
    at Pipe.<anonymous> (node:net:337:12)

But the following stack lacks Command failed with ...:

const childProcess = execa('echo', {reject: false})
childProcess.stdout.destroy(new Error('example'))
const {message, stack} = await childProcess
console.log('MESSAGE')
console.log(message)
console.log('\nSTACK')
console.log(stack)
MESSAGE
Command failed with exit code 0: echo
example

STACK
Error: example
    at file:///home/ether/code/execa/a.js:4:29
    at ModuleJob.run (node:internal/modules/esm/module_job:218:25)
    at async ModuleLoader.import (node:internal/modules/esm/loader:329:24)
    at async loadESM (node:internal/process/esm_loader:34:7)
    at async handleMainPromise (node:internal/modules/run_main:113:12)

This is due to a bug in Node.js, which is related to a quirky behavior with V8 that might or might not be a bug.

@ehmicky ehmicky changed the title error.stack is not updated when childProcess.destroy(error) is called error.stack is not updated when childProcess.destroy(error) is called (due to Node.js bug) Feb 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant