]> git.kaiwu.me - njs.git/commit
Modules: make context clone setup transactional
authorDmitry Volyntsev <xeioex@nginx.com>
Fri, 14 Aug 2026 04:22:40 +0000 (21:22 -0700)
committerDmitry Volyntsev <xeioexception@gmail.com>
Fri, 14 Aug 2026 23:05:54 +0000 (16:05 -0700)
commitbcc0a663b0991a5d46279a884e69639357da97aa
tree17ad3e65593877790d9e41b52a9d66c2d3183048
parent77957549577aaa23b458b3f4d905d2268fadfc47
Modules: make context clone setup transactional

A request can fail after a VM has been cloned, for example while
creating its request wrapper or installing the nginx pool cleanup.
The failed VM was neither destroyed nor returned to the reuse queue,
and a partially evaluated module could leave timers armed against it.
A second initialization attempt could then access rejection state from
the destroyed VM.

Keep each clone private until setup succeeds.  On failure, cancel its
events, detach request state, and destroy the VM and engine pool for
both engines.  Also clean up partially initialized QuickJS contexts and
wrapper objects.
nginx/ngx_http_js_module.c
nginx/ngx_js.c
nginx/ngx_js.h
nginx/ngx_stream_js_module.c
nginx/t/js_clone_failure.t [new file with mode: 0644]
src/qjs.c