From: Dmitry Volyntsev Date: Mon, 14 Feb 2022 14:10:26 +0000 (+0000) Subject: Fixed backtraces for native modules imported with import statement. X-Git-Tag: 0.7.3~11 X-Git-Url: http://www.kaiwu.me/postgresql/commit/static/gitweb.js?a=commitdiff_plain;h=53110d86966668658872c104f2fa7a0847f4dd12;p=njs.git Fixed backtraces for native modules imported with import statement. Previously, the module name was missing when exception is reported for a native module function imported with import statement. --- diff --git a/external/njs_crypto_module.c b/external/njs_crypto_module.c index 28b0868b..a6028289 100644 --- a/external/njs_crypto_module.c +++ b/external/njs_crypto_module.c @@ -230,6 +230,14 @@ static njs_external_t njs_ext_crypto_hmac[] = { static njs_external_t njs_ext_crypto_crypto[] = { + { + .flags = NJS_EXTERN_PROPERTY | NJS_EXTERN_SYMBOL, + .name.symbol = NJS_SYMBOL_TO_STRING_TAG, + .u.property = { + .value = "crypto", + } + }, + { .flags = NJS_EXTERN_METHOD, .name.string = njs_str("createHash"), diff --git a/external/njs_fs_module.c b/external/njs_fs_module.c index 4333abea..a586af0a 100644 --- a/external/njs_fs_module.c +++ b/external/njs_fs_module.c @@ -227,6 +227,14 @@ static njs_fs_entry_t njs_flags_table[] = { static njs_external_t njs_ext_fs[] = { + { + .flags = NJS_EXTERN_PROPERTY | NJS_EXTERN_SYMBOL, + .name.symbol = NJS_SYMBOL_TO_STRING_TAG, + .u.property = { + .value = "fs", + } + }, + { .flags = NJS_EXTERN_METHOD, .name.string = njs_str("access"), diff --git a/external/njs_query_string_module.c b/external/njs_query_string_module.c index b088e865..ae0327e5 100644 --- a/external/njs_query_string_module.c +++ b/external/njs_query_string_module.c @@ -32,6 +32,14 @@ static njs_int_t njs_query_string_init(njs_vm_t *vm); static njs_external_t njs_ext_query_string[] = { + { + .flags = NJS_EXTERN_PROPERTY | NJS_EXTERN_SYMBOL, + .name.symbol = NJS_SYMBOL_TO_STRING_TAG, + .u.property = { + .value = "querystring", + } + }, + { .flags = NJS_EXTERN_METHOD, .name.string = njs_str("parse"), diff --git a/src/test/njs_unit_test.c b/src/test/njs_unit_test.c index f666a3ea..89bc1615 100644 --- a/src/test/njs_unit_test.c +++ b/src/test/njs_unit_test.c @@ -21243,6 +21243,11 @@ static njs_unit_test_t njs_shared_test[] = " at fs.readFileSync (native)\n" " at main (:1)\n") }, + { njs_str("import fs from 'fs'; fs.readFileSync()"), + njs_str("TypeError: \"path\" must be a string or Buffer\n" + " at fs.readFileSync (native)\n" + " at main (:1)\n") }, + { njs_str("var f = new Function('return 1;'); f();"), njs_str("1") },