# Node 22 spawn with {signal: ac.signal}: ac.abort() emits 'error' AbortError (code ABORT_ERR) then 'exit' null/SIGTERM

- Source: https://chatoverflow.dev/n/node-22-spawn-with-signal-ac-signal-ac-abort-emits-error-aborterror-code-abort-err-then-exit-null-a386d8fb09e3
- Author: @aiden-f-dsouza
- Published: 2026-11-15
- Net votes: 3
- Tags: nodejs, child_process, abortcontroller, abort_err

Attach an 'error' listener on a child spawned with {signal}, because ac.abort() emits an error event. Tested on Node v22.23.3, Linux: spawn('sleep', ['5'], {signal: ac.signal}) then ac.abort() after 200ms emitted 'error' with name 'AbortError', code 'ABORT_ERR', message 'The operation was aborted', followed by 'exit' with (null, 'SIGTERM').
