]> git.kaiwu.me - njs.git/commitdiff
Fetch: fix missing event cleanup when resolver start fails
authorDmitry Volyntsev <xeioex@nginx.com>
Fri, 12 Jun 2026 00:06:32 +0000 (17:06 -0700)
committerDmitry Volyntsev <xeioexception@gmail.com>
Fri, 12 Jun 2026 03:26:59 +0000 (20:26 -0700)
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
nginx/ngx_qjs_fetch.c

index 145617f0ccec6b9a6a05022c169f8a4d86a22bdc..554f14f418540cc4b228bdfcd903fe0b0604b79e 100644 (file)
@@ -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) {
index 535773bc022ebe1977a9b236a673a3b7c65d9d70..693fb48d1cb8c602142a202b11d62f9f95d8f89e 100644 (file)
@@ -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) {