]> git.kaiwu.me - njs.git/log
njs.git
14 months agoQuickJS: removed unused variable casts introduced in 75ca26f.
Dmitry Volyntsev [Thu, 6 Feb 2025 00:26:40 +0000 (16:26 -0800)]
QuickJS: removed unused variable casts introduced in 75ca26f.

These casts were added to suppress compiler warnings during development
but are no longer needed.

14 months agoFetch: accepting response headers with underscore characters.
Dmitry Volyntsev [Sat, 22 Feb 2025 07:03:46 +0000 (23:03 -0800)]
Fetch: accepting response headers with underscore characters.

This fixes #856 on Github.

14 months agoTests: making fetch test portable by removing njs.dump().
Dmitry Volyntsev [Sat, 22 Feb 2025 06:54:00 +0000 (22:54 -0800)]
Tests: making fetch test portable by removing njs.dump().

14 months agoFixed typo introduced in 75ca26f.
Dmitry Volyntsev [Sat, 22 Feb 2025 06:10:07 +0000 (22:10 -0800)]
Fixed typo introduced in 75ca26f.

14 months agoModules: improved reporting of unhandled promise rejections.
Dmitry Volyntsev [Sat, 22 Feb 2025 04:40:14 +0000 (20:40 -0800)]
Modules: improved reporting of unhandled promise rejections.

Previously, some promise rejections were not reported.

For example:

async function timeout(ms) {
    return new Promise((resolve, reject) => {
        setTimeout(() => {
            reject(new Error('timeout'));
        }, ms);
    });
}

async function handler(r) {
    let v = await timeout(1000);
    r.return(200);
}

14 months agoTests: splitting js_periodic tests into multiple files.
Dmitry Volyntsev [Wed, 19 Feb 2025 06:53:54 +0000 (22:53 -0800)]
Tests: splitting js_periodic tests into multiple files.

14 months agoQuickJS: fixed memory leak in js_periodic handler.
Dmitry Volyntsev [Thu, 20 Feb 2025 01:36:46 +0000 (17:36 -0800)]
QuickJS: fixed memory leak in js_periodic handler.

14 months agoQuickJS: fixed SharedDict.incr() with empty init argument.
Dmitry Volyntsev [Thu, 20 Feb 2025 00:50:15 +0000 (16:50 -0800)]
QuickJS: fixed SharedDict.incr() with empty init argument.

14 months agoQuickJS: added WebCrypto import tests forgotten in 75ca26f.
Dmitry Volyntsev [Thu, 13 Feb 2025 02:07:26 +0000 (18:07 -0800)]
QuickJS: added WebCrypto import tests forgotten in 75ca26f.

Import related tests are consolidated from other WebCrypto tests.

14 months agoQuickJS: added missed OPENSSL context for errors in WebCrypto.
Dmitry Volyntsev [Thu, 13 Feb 2025 02:13:54 +0000 (18:13 -0800)]
QuickJS: added missed OPENSSL context for errors in WebCrypto.

14 months agoQuickJS: fixed key usage processing with invalid values in WebCrypto.
Dmitry Volyntsev [Thu, 13 Feb 2025 02:12:38 +0000 (18:12 -0800)]
QuickJS: fixed key usage processing with invalid values in WebCrypto.

14 months agoQuickJS: fixed non-NULL terminated strings formatting in exceptions.
Dmitry Volyntsev [Thu, 13 Feb 2025 03:11:08 +0000 (19:11 -0800)]
QuickJS: fixed non-NULL terminated strings formatting in exceptions.

When "%*s" is specified, the first integer is interpreted as width.
Width specifies *minimum* number of characters to output. The next
string is expected to be NULL-terminated.

When "%.*s" is specified, the first integer is interpreted as precision.
Precision specifies *maximum* number of characters to output.

14 months agoFixed access to uninitialized alg in SubtleCrypto.import().
Dmitry Volyntsev [Wed, 12 Feb 2025 00:41:56 +0000 (16:41 -0800)]
Fixed access to uninitialized alg in SubtleCrypto.import().

Found by GCC:
In function ‘qjs_import_jwk_oct’,
external/qjs_webcrypto_module.c:3116:13: error: ‘alg.start’ may be used uninitialized [-Werror=maybe-uninitialized]
 3116 |             JS_ThrowTypeError(cx, "key size and \"alg\" value \"%s\" mismatch",

The similar place in the NJS module was also fixed.

14 months agoAdd missed syntax error for await in template literal.
Vadim Zhestikov [Tue, 11 Feb 2025 23:39:29 +0000 (15:39 -0800)]
Add missed syntax error for await in template literal.

This fixes issues #836 on github.

14 months agoModules: fixed name corruption in variable and header processing.
Dmitry Volyntsev [Sat, 8 Feb 2025 01:23:09 +0000 (17:23 -0800)]
Modules: fixed name corruption in variable and header processing.

The HTTP and Stream JS modules were performing in-place lowercasing of
variable and header names, which could inadvertently overwrite the
original data.

In the NJS engine, the problem did not manifest itself for strings up to
14 bytes long because they are inlined into the value.

15 months agoQuickJS: added querystring module.
Dmitry Volyntsev [Thu, 30 Jan 2025 05:35:08 +0000 (21:35 -0800)]
QuickJS: added querystring module.

15 months agoQuickJS: fixed shared dict in stream module.
Dmitry Volyntsev [Mon, 3 Feb 2025 17:07:22 +0000 (09:07 -0800)]
QuickJS: fixed shared dict in stream module.

The change was missed in 352c2e59 (0.8.8).

15 months agoTests262: fixed merge() with null values.
Dmitry Volyntsev [Fri, 31 Jan 2025 03:10:29 +0000 (19:10 -0800)]
Tests262: fixed merge() with null values.

15 months agoHTTP: reading r.requestText or r.requestBuffer from a temp file.
Dmitry Volyntsev [Wed, 29 Jan 2025 03:11:48 +0000 (19:11 -0800)]
HTTP: reading r.requestText or r.requestBuffer from a temp file.

Previously, an exception was thrown when accessing r.requestText or
r.requestBuffer if a client request body size exceeded
client_body_buffer_size.

15 months agoQuickJS: added WebCrypto module.
Dmitry Volyntsev [Fri, 10 Jan 2025 03:25:58 +0000 (19:25 -0800)]
QuickJS: added WebCrypto module.

15 months agoCI: added test with QuickJS-NG in check-pr job.
Dmitry Volyntsev [Thu, 23 Jan 2025 02:03:55 +0000 (18:03 -0800)]
CI: added test with QuickJS-NG in check-pr job.

15 months agoQuickJS: added support for QuickJS-NG library.
Dmitry Volyntsev [Wed, 22 Jan 2025 01:09:06 +0000 (17:09 -0800)]
QuickJS: added support for QuickJS-NG library.

15 months agoQuickJS: correctly handling value len for empty query params.
Dmitry Volyntsev [Thu, 23 Jan 2025 01:44:11 +0000 (17:44 -0800)]
QuickJS: correctly handling value len for empty query params.

15 months agoQuickJS: reimplemented process.argv.
Dmitry Volyntsev [Wed, 22 Jan 2025 02:07:53 +0000 (18:07 -0800)]
QuickJS: reimplemented process.argv.

Without using JS_SetOpaque(), because in QuickJS-NG opaque pointer
cannot be set for internal classes, including ordinary objects.

15 months agoVersion bump.
Dmitry Volyntsev [Thu, 23 Jan 2025 23:45:43 +0000 (15:45 -0800)]
Version bump.

15 months agoQuickJS: fixed Buffer.concat() with a single argument.
Dmitry Volyntsev [Fri, 17 Jan 2025 01:36:44 +0000 (17:36 -0800)]
QuickJS: fixed Buffer.concat() with a single argument.

15 months agoQuickJS: added TextDecoder and TextEncoder.
Dmitry Volyntsev [Sat, 11 Jan 2025 07:20:36 +0000 (23:20 -0800)]
QuickJS: added TextDecoder and TextEncoder.

15 months agoQuickJS: accept ArrayBuffer as an arument for qjs_typed_array_data().
Dmitry Volyntsev [Tue, 14 Jan 2025 06:00:10 +0000 (22:00 -0800)]
QuickJS: accept ArrayBuffer as an arument for qjs_typed_array_data().

15 months agoTests: moving request body tests to js_request_body.t.
Dmitry Volyntsev [Sat, 18 Jan 2025 01:19:00 +0000 (17:19 -0800)]
Tests: moving request body tests to js_request_body.t.

15 months agoTests: added request body test when body is in a file.
Dmitry Volyntsev [Sat, 18 Jan 2025 01:03:08 +0000 (17:03 -0800)]
Tests: added request body test when body is in a file.

15 months agoVersion 0.8.9. 0.8.9
Dmitry Volyntsev [Mon, 13 Jan 2025 22:56:10 +0000 (14:56 -0800)]
Version 0.8.9.

15 months ago2025 year.
Dmitry Volyntsev [Mon, 13 Jan 2025 22:58:28 +0000 (14:58 -0800)]
2025 year.

16 months agoModules: removed extra VM creation per server.
Dmitry Volyntsev [Sat, 4 Jan 2025 06:25:15 +0000 (22:25 -0800)]
Modules: removed extra VM creation per server.

Previously, when js_import was declared in http or stream blocks, an extra
copy of the VM instance was created for each server block. This was not
needed and consumed a lot of memory for configurations with many server
blocks.

This issue was introduced in 9b674412 (0.8.6) and was
partially fixed for location blocks only in 685b64f0 (0.8.7).

16 months agoVersion bump.
Dmitry Volyntsev [Mon, 6 Jan 2025 17:09:43 +0000 (09:09 -0800)]
Version bump.

16 months agoQuickJS: added fs module.
Dmitry Volyntsev [Thu, 5 Dec 2024 01:31:23 +0000 (17:31 -0800)]
QuickJS: added fs module.

16 months agoTest262: running tests within their own directory.
Dmitry Volyntsev [Sat, 14 Dec 2024 06:43:25 +0000 (22:43 -0800)]
Test262: running tests within their own directory.

16 months agoTest262: skipping individual tests.
Dmitry Volyntsev [Fri, 6 Dec 2024 03:53:11 +0000 (19:53 -0800)]
Test262: skipping individual tests.

16 months agoTest262: collecting all tests results before exiting.
Dmitry Volyntsev [Fri, 6 Dec 2024 00:09:38 +0000 (16:09 -0800)]
Test262: collecting all tests results before exiting.

16 months agoTest262: renaming fs tests.
Dmitry Volyntsev [Thu, 5 Dec 2024 02:00:57 +0000 (18:00 -0800)]
Test262: renaming fs tests.

16 months agoTest262: making "fs" module required.
Dmitry Volyntsev [Thu, 5 Dec 2024 01:07:22 +0000 (17:07 -0800)]
Test262: making "fs" module required.

16 months agoTest262: fixed check for crypto object.
Dmitry Volyntsev [Thu, 5 Dec 2024 01:52:32 +0000 (17:52 -0800)]
Test262: fixed check for crypto object.

16 months agoTests: skipping stream_js_periodic.t for QuickJS engine.
Dmitry Volyntsev [Sat, 7 Dec 2024 01:37:22 +0000 (17:37 -0800)]
Tests: skipping stream_js_periodic.t for QuickJS engine.

17 months agoVersion 0.8.8. 0.8.8
Dmitry Volyntsev [Mon, 9 Dec 2024 22:27:30 +0000 (14:27 -0800)]
Version 0.8.8.

17 months agoFetch: optimized use of SSL contexts.
Dmitry Volyntsev [Tue, 3 Dec 2024 02:46:45 +0000 (18:46 -0800)]
Fetch: optimized use of SSL contexts.

To ensure optimal use of memory, SSL contexts for ngx.fetch() are now
inherited from previous levels as long as relevant js_fetch_* directives
are not redefined.

17 months agoHTTP: fixed limit rated output.
Dmitry Volyntsev [Tue, 26 Nov 2024 05:43:44 +0000 (21:43 -0800)]
HTTP: fixed limit rated output.

Previously, when r.return(code, body) was called from a subrequest
handler with a body size larger than the sendfile_max_chunk value
connection hanging might occur.

17 months agoModules: refactored preloading.
Dmitry Volyntsev [Thu, 14 Nov 2024 06:03:14 +0000 (22:03 -0800)]
Modules: refactored preloading.

17 months agoAllow to execute some code before cloning.
Dmitry Volyntsev [Wed, 13 Nov 2024 22:50:20 +0000 (14:50 -0800)]
Allow to execute some code before cloning.

17 months agoFixed absolute scope in cloned VMs.
Dmitry Volyntsev [Thu, 14 Nov 2024 05:14:34 +0000 (21:14 -0800)]
Fixed absolute scope in cloned VMs.

17 months agoThrowing exception when prototype is not found.
Dmitry Volyntsev [Wed, 13 Nov 2024 06:57:48 +0000 (22:57 -0800)]
Throwing exception when prototype is not found.

18 months agoFixed resolving when Promise is inherited.
Dmitry Volyntsev [Fri, 8 Nov 2024 02:41:41 +0000 (18:41 -0800)]
Fixed resolving when Promise is inherited.

Previously, njs_promise_resolve() might return njs_object_t instead of
njs_promise_t. Later an instance of njs_object_t was put into a
NJS_PROMISE value. Whereas njs_promise_t is always expected to be inside
of a NJS_PROMISE value.

This closes #813 issue on Github.

18 months agoAdded missing steps for building with QuickJS to README.
Dmitry Volyntsev [Thu, 7 Nov 2024 23:26:39 +0000 (15:26 -0800)]
Added missing steps for building with QuickJS to README.

18 months agoXML: improved XMLNode.$tags handler.
Dmitry Volyntsev [Thu, 7 Nov 2024 06:15:22 +0000 (22:15 -0800)]
XML: improved XMLNode.$tags handler.

18 months agoXML: fixed tests with libxml2 2.13 and later.
Dmitry Volyntsev [Thu, 7 Nov 2024 06:08:21 +0000 (22:08 -0800)]
XML: fixed tests with libxml2 2.13 and later.

This fixes #812 issue on Github.

18 months agoFixed building by Clang.
Dmitry Volyntsev [Wed, 6 Nov 2024 23:59:32 +0000 (15:59 -0800)]
Fixed building by Clang.

src/qjs.c:347:19: error: variable 'signo' may be uninitialized when used
here [-Werror,-Wconditional-uninitialized]
  347 |     if (kill(pid, signo) < 0) {
      |                   ^~~~~
src/qjs.c:294:31: note: initialize the variable 'signo' to silence this
warning
  294 |     int                  signo, pid;
      |                               ^
      |                                = 0
1 error generated.

18 months agoFS: removed fs.promises.readSync() added by mistake.
Dmitry Volyntsev [Wed, 6 Nov 2024 03:01:52 +0000 (19:01 -0800)]
FS: removed fs.promises.readSync() added by mistake.

This closes #810 issue on Github.

18 months agoModules: fixed process.env object.
Dmitry Volyntsev [Wed, 6 Nov 2024 02:19:48 +0000 (18:19 -0800)]
Modules: fixed process.env object.

Previously, it ignored changes to environment variables introduced
with "env" directive.

18 months agoIntroduced process.kill() function.
Stefan Sundin [Fri, 25 Oct 2024 19:50:45 +0000 (12:50 -0700)]
Introduced process.kill() function.

18 months agoQuickJS: introduced process.kill().
Dmitry Volyntsev [Fri, 1 Nov 2024 01:15:22 +0000 (18:15 -0700)]
QuickJS: introduced process.kill().

18 months agoQuickJS: reworked process object.
Dmitry Volyntsev [Fri, 1 Nov 2024 00:47:41 +0000 (17:47 -0700)]
QuickJS: reworked process object.

18 months agoModules: added js_shared_dict_zone support in QuickJS engine.
Dmitry Volyntsev [Fri, 25 Oct 2024 02:00:41 +0000 (19:00 -0700)]
Modules: added js_shared_dict_zone support in QuickJS engine.

18 months agoTests: removed njs specific code from js_shared_dict.t.
Dmitry Volyntsev [Tue, 29 Oct 2024 00:08:40 +0000 (17:08 -0700)]
Tests: removed njs specific code from js_shared_dict.t.

18 months agoQuickJS: improved library discovery.
Dmitry Volyntsev [Wed, 23 Oct 2024 01:50:46 +0000 (18:50 -0700)]
QuickJS: improved library discovery.

Add explicit testing for JS_GetClassID() function since it is not available
in older QuickJS versions.

This closes #801 issue on Github.

18 months agoUpdated README with QuickJS module build instructions.
Dmitry Volyntsev [Wed, 23 Oct 2024 01:10:25 +0000 (18:10 -0700)]
Updated README with QuickJS module build instructions.

18 months agoVersion bump.
Dmitry Volyntsev [Wed, 23 Oct 2024 00:31:19 +0000 (17:31 -0700)]
Version bump.

18 months agoVersion 0.8.7. 0.8.7
Dmitry Volyntsev [Tue, 22 Oct 2024 01:04:48 +0000 (18:04 -0700)]
Version 0.8.7.

18 months agoImproved error messages for module loading failures.
Dmitry Volyntsev [Sat, 19 Oct 2024 01:24:49 +0000 (18:24 -0700)]
Improved error messages for module loading failures.

There are several reasons why a file cannot be opened. Without
extra information, especially in containerized environments, these
problems are difficult to debug. Adding errno status to the
error output helps identify the root cause.

Additionally, error messages are now aligned between njs and QuickJS.

18 months agoFS: introduced fs.readlinkSync() and friends.
Dmitry Volyntsev [Sat, 19 Oct 2024 05:01:58 +0000 (22:01 -0700)]
FS: introduced fs.readlinkSync() and friends.

This closes #802 feature request on Github.

18 months agoTests: added js_body_filter test with non-UTF8 data.
Dmitry Volyntsev [Fri, 18 Oct 2024 01:44:17 +0000 (18:44 -0700)]
Tests: added js_body_filter test with non-UTF8 data.

To test for implicit UTF8 conversion.

18 months agoHTTP: added strict check for js_body_filter syntax.
Dmitry Volyntsev [Fri, 18 Oct 2024 01:31:26 +0000 (18:31 -0700)]
HTTP: added strict check for js_body_filter syntax.

18 months agoImplemented lazy stack symbolization.
Dmitry Volyntsev [Wed, 16 Oct 2024 01:28:19 +0000 (18:28 -0700)]
Implemented lazy stack symbolization.

Previously, when an exception was thrown, the exception got 'stack'
property attached which contained the backtrace information about where
the exception happened. This could be a heavy operation and it was not
always needed.

To optimize it, the process is split into 2 phases. The first phase
collects all the necessary info about the current stack. The second
phase, where the stack symbolization happens, occurs only when this
property is referenced.

18 months agoCI: aligned asan build with with post-commit CI asan build.
Dmitry Volyntsev [Tue, 15 Oct 2024 06:12:16 +0000 (23:12 -0700)]
CI: aligned asan build with with post-commit CI asan build.

18 months agoFixed dead store assignment in r.subrequest().
Dmitry Volyntsev [Sat, 12 Oct 2024 01:41:27 +0000 (18:41 -0700)]
Fixed dead store assignment in r.subrequest().

Found by Clang static analyzer.

18 months agoModules: removed extra VMs creation when it is not needed.
Dmitry Volyntsev [Sat, 12 Oct 2024 00:23:42 +0000 (17:23 -0700)]
Modules: removed extra VMs creation when it is not needed.

Previously, a new VM instance was created for every location. This is
not needed and consumes a lot of memory for large configurations.
Instead, if no new js_import is introduced on the location level server
level VM should be used.

The issue was introduced in 9b674412 (0.8.6).

This fixes #795 issue on Github.

19 months agoFixed Buffer.prototype.indexOf() on 32bits platforms.
Dmitry Volyntsev [Thu, 10 Oct 2024 23:33:13 +0000 (16:33 -0700)]
Fixed Buffer.prototype.indexOf() on 32bits platforms.

19 months agoCI: added 32bit test in check-pr job.
Dmitry Volyntsev [Fri, 11 Oct 2024 01:03:38 +0000 (18:03 -0700)]
CI: added 32bit test in check-pr job.

19 months agoFixed Buffer.prototype.indexOf() and friends.
Dmitry Volyntsev [Thu, 10 Oct 2024 01:25:52 +0000 (18:25 -0700)]
Fixed Buffer.prototype.indexOf() and friends.

With empty buffers in both the self and search cases.

19 months agoFixed Buffer.prototype.lastIndexOf() when `from` is provided.
Dmitry Volyntsev [Thu, 10 Oct 2024 00:59:26 +0000 (17:59 -0700)]
Fixed Buffer.prototype.lastIndexOf() when `from` is provided.

Previous incorrect fix was introduced in 5d15a8d6 (0.8.5).

19 months agoFixed heap-buffer-overflow in Buffer.prototype.indexOf().
Dmitry Volyntsev [Thu, 10 Oct 2024 00:32:11 +0000 (17:32 -0700)]
Fixed heap-buffer-overflow in Buffer.prototype.indexOf().

Previously, when `from` argument was provided heap-buffer-overflow might
happen due to lack of boundary check. `to = njs_min(to, length)`
statement was also removed because it has no effect, `to` is
equal to `length` here.

The issue was introduced in 5d15a8d6 (0.8.5).

This closes #794 issue on Github.

19 months agoTest262: reporting name of the testsuite for a failed test.
Dmitry Volyntsev [Wed, 9 Oct 2024 23:05:26 +0000 (16:05 -0700)]
Test262: reporting name of the testsuite for a failed test.

19 months agoOptimized qjs_to_bytes().
Dmitry Volyntsev [Tue, 8 Oct 2024 05:46:40 +0000 (22:46 -0700)]
Optimized qjs_to_bytes().

Doing JS_IsString() check first before a heavy-weight call to
JS_GetTypedArrayBuffer() which throws an exception when argument is not
a typed array.

19 months agoOptimized ngx_qjs_string().
Dmitry Volyntsev [Tue, 8 Oct 2024 05:41:24 +0000 (22:41 -0700)]
Optimized ngx_qjs_string().

Doing JS_IsString() check first before a heavy-weight call to
JS_GetTypedArrayBuffer() which throws an exception when argument is not
a typed array.

19 months agoBenchmark: code is rewritten using public API.
Dmitry Volyntsev [Tue, 8 Oct 2024 02:08:53 +0000 (19:08 -0700)]
Benchmark: code is rewritten using public API.

19 months agoRemoved deprecated njs_string_set().
Dmitry Volyntsev [Tue, 8 Oct 2024 01:51:03 +0000 (18:51 -0700)]
Removed deprecated njs_string_set().

19 months agoStyle.
Dmitry Volyntsev [Tue, 8 Oct 2024 01:12:12 +0000 (18:12 -0700)]
Style.

19 months agoFixed dead store assignment in TextEncoder.encodeInto().
Dmitry Volyntsev [Wed, 25 Sep 2024 05:07:44 +0000 (22:07 -0700)]
Fixed dead store assignment in TextEncoder.encodeInto().

Found by Clang static analyzer.

19 months agoTests: external code for unit tests is rewritten using public API.
Dmitry Volyntsev [Tue, 8 Oct 2024 00:57:08 +0000 (17:57 -0700)]
Tests: external code for unit tests is rewritten using public API.

This part was missed in 24b56ef88 (0.8.0).

19 months agoRemoved deprecated $262.byteString().
Dmitry Volyntsev [Tue, 8 Oct 2024 00:50:19 +0000 (17:50 -0700)]
Removed deprecated $262.byteString().

19 months agoVersion bump.
Dmitry Volyntsev [Tue, 8 Oct 2024 01:09:47 +0000 (18:09 -0700)]
Version bump.

19 months agoVersion 0.8.6. 0.8.6
Dmitry Volyntsev [Fri, 27 Sep 2024 00:47:07 +0000 (17:47 -0700)]
Version 0.8.6.

19 months agoCI: Run a check-pr job on a specific Ubuntu version.
Konstantin Pavlov [Thu, 26 Sep 2024 20:41:42 +0000 (13:41 -0700)]
CI: Run a check-pr job on a specific Ubuntu version.

GitHub is going to change the latest tag to point to 24.04 soon, so
let's be proactive and pin to a specific version.

With that change, we'd also need to drop the _FORTIFY_SOURCE definition
since it now has a stricter default on Ubuntu 24.04.

19 months agoHTTP: fixed r.return() with empty string as a body argument.
Dmitry Volyntsev [Wed, 18 Sep 2024 05:58:31 +0000 (22:58 -0700)]
HTTP: fixed r.return() with empty string as a body argument.

19 months agoHTTP: fixed r.subrequest() check for nested subrequests.
Dmitry Volyntsev [Wed, 18 Sep 2024 02:17:09 +0000 (19:17 -0700)]
HTTP: fixed r.subrequest() check for nested subrequests.

The issue was introduced in a14be61c86 (0.8.5).

This fixes #783 on Github.

19 months agoModules: introduced QuickJS engine.
Dmitry Volyntsev [Sat, 15 Jun 2024 03:54:28 +0000 (20:54 -0700)]
Modules: introduced QuickJS engine.

"js_engine" directive is introduced which sets JavaScript engine.
When the module is built with QuickJS library "js_engine qjs;" sets
QuickJS engine for the current block. By default njs engine is used.

For example,

nginx.conf:

    location /a {
        js_engine qjs;
        # will be handled by QuickJS
        js_content main.handler;
    }

    location /b {
        # will be handled by njs
        js_content main.handler;
    }

QuickJS engine implements drop-in replacement for nginx/njs objects
with the following exceptions:

    * nginx module API to be added later: ngx.fetch(), ngx.shared.dict.
    * Built-in modules to be added later: fs, crypto, WebCrypto, xml.
    * NJS specific API: njs.dump(), njs.on(), console.dump().
    * js_preload_object directive.

19 months agoModules: introduced engine API.
Dmitry Volyntsev [Tue, 11 Jun 2024 05:58:24 +0000 (22:58 -0700)]
Modules: introduced engine API.

No functional changes.

19 months agoCI: removed DUMP_LEAKS flag from QuickJS build.
Dmitry Volyntsev [Thu, 12 Sep 2024 04:53:38 +0000 (21:53 -0700)]
CI: removed DUMP_LEAKS flag from QuickJS build.

While it is useful for debugging what objects are leaking at the end
this flag hides QuickJS JSString leaks from Address Sanitizer.

19 months agoConfigure: accept spaces in PATH.
Vadim Zhestikov [Fri, 6 Sep 2024 02:31:28 +0000 (19:31 -0700)]
Configure: accept spaces in PATH.

20 months agoFixed handling of encode arg in fs.readdir() and fs.realpath().
Dmitry Volyntsev [Wed, 4 Sep 2024 04:32:33 +0000 (21:32 -0700)]
Fixed handling of encode arg in fs.readdir() and fs.realpath().

The issue was introduced in 98c6570f3 (0.8.0).

20 months agoTests: making exception test more portable in stream_js.t.
Dmitry Volyntsev [Wed, 28 Aug 2024 23:57:49 +0000 (16:57 -0700)]
Tests: making exception test more portable in stream_js.t.

20 months agoQuickJS: disabling eval() and Function() in qjs_new_context().
Dmitry Volyntsev [Wed, 24 Jul 2024 23:30:10 +0000 (16:30 -0700)]
QuickJS: disabling eval() and Function() in qjs_new_context().

This properly disables eval() after previous attempt in c773ebcaad
(0.8.5).  In QuickJS buint-in C level eval API, which is used by njs, is
linked to eval() in JS code. To disable only the JS function
manual modification of global object is required.

20 months agoQuickJS: added wrappers for strings creation.
Dmitry Volyntsev [Sat, 17 Aug 2024 06:29:48 +0000 (23:29 -0700)]
QuickJS: added wrappers for strings creation.