]> git.kaiwu.me - njs.git/commitdiff
Shell: stopping events handling for uncaught exception in file mode.
authorDmitry Volyntsev <xeioex@nginx.com>
Thu, 26 Dec 2019 11:53:52 +0000 (14:53 +0300)
committerDmitry Volyntsev <xeioex@nginx.com>
Thu, 26 Dec 2019 11:53:52 +0000 (14:53 +0300)
This closes #269 issue on Github.

src/njs_shell.c
test/njs_expect_test.exp

index b68e058c11299ddcf7688876be37e7344b6612b3..cad7e3ab5e38e4ecf720cfd6cdc19d2f37e396ee 100644 (file)
@@ -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;
+            }
         }
     }
 
index b3eb186f5e80db7f09e8c0965cbbcdcd347ce4df..574bc729a69185e34c124aad3df1323e5384b393 100644 (file)
@@ -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"} \