From eb24b770caf868b5892f05080d07c8843ef134ae Mon Sep 17 00:00:00 2001 From: Alexander Borisov Date: Thu, 26 Nov 2020 21:43:17 +0300 Subject: [PATCH] Modules: fixed promise events handling. Previously, promise chain might not be invoked at all in some cases. Specifically, this happened in HTTP module if promise chain did not start with a r.subrequest() invocation. The fix is to always process all pending promise events after the main module function. This closes #359 issue on GitHub. --- nginx/ngx_js.c | 6 +----- src/njs_vm.c | 2 +- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/nginx/ngx_js.c b/nginx/ngx_js.c index 976f3b76..56b2bdd4 100644 --- a/nginx/ngx_js.c +++ b/nginx/ngx_js.c @@ -79,11 +79,7 @@ ngx_js_call(njs_vm_t *vm, ngx_str_t *fname, njs_opaque_value_t *value, return NGX_ERROR; } - if (njs_vm_pending(vm)) { - return NGX_AGAIN; - } - - return NGX_OK; + return njs_vm_run(vm); } diff --git a/src/njs_vm.c b/src/njs_vm.c index 56587277..2aa8461b 100644 --- a/src/njs_vm.c +++ b/src/njs_vm.c @@ -578,7 +578,7 @@ njs_vm_handle_events(njs_vm_t *vm) } while (!njs_queue_is_empty(promise_events)); - return njs_posted_events(vm) ? NJS_AGAIN : NJS_OK; + return njs_vm_pending(vm) ? NJS_AGAIN : NJS_OK; } -- 2.47.3