details: https://hg.nginx.org/njs/rev/046a493850bc branches: changeset: 1999:046a493850bc user: Dmitry Volyntsev <xei...@nginx.com> date: Tue Nov 15 18:38:49 2022 -0800 description: Modules: fixed Fetch Response prototype reinitialization.
Previously, since 446a1cb64a6a (0.7.7), when at least one js_import directive was declared in both HTTP and Stream, ngx.fetch() returned inapproriate response in Stream. The prototype for Response object was created two times for HTTP and STREAM, but the second initialization of global variable with the index of the Response() prototype overwrites the first value with a different value. This caused a problem in Stream code which manifested itself as a `Stream flags` object returned as a result of ngx.fetch() call instead of a Response instance. The fix is to ensure that shared prototypes like a Response prototype have indentical index value in all the modules. This fixes #596 issue on Github. diffstat: nginx/ngx_js.c | 13 +++++++++---- 1 files changed, 9 insertions(+), 4 deletions(-) diffs (26 lines): diff -r 993f19791a71 -r 046a493850bc nginx/ngx_js.c --- a/nginx/ngx_js.c Mon Nov 14 17:31:03 2022 -0800 +++ b/nginx/ngx_js.c Tue Nov 15 18:38:49 2022 -0800 @@ -953,13 +953,18 @@ ngx_js_init_conf_vm(ngx_conf_t *cf, ngx_ } } - rc = externals_init(cf, conf); - if (rc != NGX_OK) { + /* + * Core prototypes must be inited before externals_init() because + * the core prototype ids have to be identical in all the modules. + */ + + rc = ngx_js_core_init(conf->vm, cf->log); + if (njs_slow_path(rc != NJS_OK)) { return NGX_ERROR; } - rc = ngx_js_core_init(conf->vm, cf->log); - if (njs_slow_path(rc != NJS_OK)) { + rc = externals_init(cf, conf); + if (rc != NGX_OK) { return NGX_ERROR; } _______________________________________________ nginx-devel mailing list -- nginx-devel@nginx.org To unsubscribe send an email to nginx-devel-le...@nginx.org