]> git.kaiwu.me - njs.git/commitdiff
QuickJS: stop tracking rejections during final report
authorDmitry Volyntsev <xeioex@nginx.com>
Mon, 28 Sep 2026 22:42:40 +0000 (15:42 -0700)
committerDmitry Volyntsev <xeioexception@gmail.com>
Tue, 29 Sep 2026 18:57:53 +0000 (11:57 -0700)
Converting the rejection reason to a log string may reject another
promise.  Disable the tracker before reporting so new rejections
cannot leave references in the request context after its list has
been drained.

nginx/ngx_js.c

index cfa9ec14dbd1f02edc5d95a8858dc8524d7fcefb..b7d04a5d4a4db4b1555d30d525d722c9c010182d 100644 (file)
@@ -1378,11 +1378,12 @@ ngx_engine_qjs_destroy(ngx_engine_t *e, ngx_js_ctx_t *ctx,
 
         ngx_qjs_clear_events(ctx);
 
+        JS_SetHostPromiseRejectionTracker(JS_GetRuntime(cx), NULL, NULL);
+
         if (ngx_qjs_unhandled_rejection(ctx)) {
             ngx_qjs_log_exception(e, ctx->log, "unhandled rejection");
         }
 
-        JS_SetHostPromiseRejectionTracker(JS_GetRuntime(cx), NULL, NULL);
         ngx_qjs_detach_ctx(ctx, cx);
 
         if (JS_IsJobPending(JS_GetRuntime(cx))) {