]> git.kaiwu.me - njs.git/commit
QuickJS: fix compatibility with quickjs-ng 0.16.0 and later
authorDmitry Volyntsev <xeioex@nginx.com>
Mon, 17 Aug 2026 16:33:34 +0000 (09:33 -0700)
committerDmitry Volyntsev <xeioexception@gmail.com>
Thu, 20 Aug 2026 17:31:10 +0000 (10:31 -0700)
commitde76bf747641df80249a9047bb5f2b5c4bcbc1c0
tree03d6742336374862be4261cca059e6b122bfcba7
parentbcc0a663b0991a5d46279a884e69639357da97aa
QuickJS: fix compatibility with quickjs-ng 0.16.0 and later

Two separate problems prevented njs from working with the recent
quickjs-ng releases.

JS_NewArrayBuffer() has grown a "max_len" argument and its free callback
has become a realloc one.  The calls are wrapped now, the callback has
to implement the whole realloc contract, because transfer() reallocates
the data even for a buffer which is not resizable.

The class ids used by njs started at 64, while the engine reserves the
ids below JS_CLASS_INIT_COUNT, which has reached 67.  JS_NewClass()
failed with a collision and the context could not be created.  The ids
are moved above the engine range and the remaining unchecked
JS_NewClass() calls now report the failure.

This fixes #1113 issue on Github.
auto/quickjs
external/njs_shell.c
nginx/ngx_http_js_module.c
nginx/ngx_qjs_fetch.c
src/qjs.c
src/qjs.h
src/qjs_buffer.c