From: Dmitry Volyntsev Date: Thu, 26 Dec 2019 11:53:52 +0000 (+0300) Subject: Shell: stopping events handling for uncaught exception in file mode. X-Git-Tag: 0.3.8~18 X-Git-Url: http://git.kaiwu.me/sitemap.xml?a=commitdiff_plain;h=22de386ca4dd8c83d87e1e2a08f53d0dfe313c64;p=njs.git Shell: stopping events handling for uncaught exception in file mode. This closes #269 issue on Github. --- diff --git a/src/njs_shell.c b/src/njs_shell.c index b68e058c..cad7e3ab 100644 --- a/src/njs_shell.c +++ b/src/njs_shell.c @@ -809,6 +809,10 @@ njs_process_script(njs_opts_t *opts, njs_console_t *console, njs_output(opts, vm, ret); + if (!opts->interactive && ret == NJS_ERROR) { + return NJS_ERROR; + } + for ( ;; ) { if (!njs_vm_pending(vm)) { break; @@ -833,6 +837,10 @@ njs_process_script(njs_opts_t *opts, njs_console_t *console, if (ret == NJS_ERROR) { njs_output(opts, vm, ret); + + if (!opts->interactive) { + return NJS_ERROR; + } } } diff --git a/test/njs_expect_test.exp b/test/njs_expect_test.exp index b3eb186f..574bc729 100644 --- a/test/njs_expect_test.exp +++ b/test/njs_expect_test.exp @@ -699,6 +699,17 @@ njs_test { "Error: Not a directory*"} } +njs_run {"-c" "setTimeout(() => {console.log('A'.repeat(1024))}, 0); ref"} \ +"^Thrown: +ReferenceError: \"ref\" is not defined in string:1 + at main \\\(native\\\)\n$" + +njs_run {"-c" "setTimeout(() => {ref}, 0); setTimeout(() => {console.log('A'.repeat(1024))}, 0)"} \ +"^Thrown: +ReferenceError: \"ref\" is not defined in string:1 + at anonymous \\\(native\\\) + at main \\\(native\\\)\n$" + # Modules njs_run {"-p" "test/module/libs" "./test/module/normal.js"} \