From 0365e3ad0d822c8d49d58a324b46cb15aa99195c Mon Sep 17 00:00:00 2001 From: Dmitry Volyntsev Date: Thu, 11 Jun 2026 17:06:32 -0700 Subject: [PATCH] Fetch: fix missing event cleanup when resolver start fails Previously, when the resolver context allocation failed, both engines returned without deleting the registered fetch event and reported the error with a synchronous throw instead of rejecting the returned promise, unlike all other failure paths. --- nginx/ngx_js_fetch.c | 2 +- nginx/ngx_qjs_fetch.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/nginx/ngx_js_fetch.c b/nginx/ngx_js_fetch.c index 145617f0..554f14f4 100644 --- a/nginx/ngx_js_fetch.c +++ b/nginx/ngx_js_fetch.c @@ -645,7 +645,7 @@ ngx_js_ext_fetch(njs_vm_t *vm, njs_value_t *args, njs_uint_t nargs, if (ctx == NULL) { njs_vm_memory_error(vm); - return NJS_ERROR; + goto fail; } if (ctx == NGX_NO_RESOLVER) { diff --git a/nginx/ngx_qjs_fetch.c b/nginx/ngx_qjs_fetch.c index 535773bc..693fb48d 100644 --- a/nginx/ngx_qjs_fetch.c +++ b/nginx/ngx_qjs_fetch.c @@ -385,8 +385,8 @@ ngx_qjs_ext_fetch(JSContext *cx, JSValueConst this_val, int argc, ngx_qjs_external_resolver_timeout(cx, external)); if (rs == NULL) { - JS_FreeValue(cx, promise); - return JS_ThrowOutOfMemory(cx); + JS_ThrowOutOfMemory(cx); + goto fail; } if (rs == NGX_NO_RESOLVER) { -- 2.47.3