Closed
Description
- Version: v13.0.0-pre
- Platform: Linux (debian)
- Subsystem: Domain
It appears that the TickObject
used for process.nextTick
can die between the tick callback and the tick's after
hook (possibly only in the case where the callback throws an exception), in which case there is no longer a strong reference to the tick's domain and the WeakReference
to the domain can die (on an unlucky GC run). Then, the exit()
call in domain.js
will be called on undefined, and will crash.
Depending on the desired semantics, either current.get()
in the after()
call should check the WeakReference
, or the TickObject
resource/domain should be kept strongly alive until after the after
hook.
Reproducible by manually setting a tighter GC interval and stressing compaction on a debug node build:
$ node --gc-interval=100 --stress-compaction test/parallel/test-domain-error-types.js
TypeError: Cannot read property 'exit' of undefined
at AsyncHook.after (domain.js:82:20)
at emitHook (internal/async_hooks.js:164:38)
at emitAfterScript (internal/async_hooks.js:363:5)
at process._fatalException (internal/process/execution.js:180:9)