diff options
author | Dmitry Volyntsev <xeioex@nginx.com> | 2022-06-02 16:32:38 -0700 |
---|---|---|
committer | Dmitry Volyntsev <xeioex@nginx.com> | 2022-06-02 16:32:38 -0700 |
commit | d09868bc71f9a990445959329ad8c1b10d3898f5 (patch) | |
tree | 0dabdfd057344e53f2e0b68f7fdf979448240d13 /test/js/async_exception_in_await.t.js | |
parent | 04f59f9defeeb618260e620bb11466741c0e41e5 (diff) | |
download | njs-d09868bc71f9a990445959329ad8c1b10d3898f5.tar.gz njs-d09868bc71f9a990445959329ad8c1b10d3898f5.zip |
Fixed njs_vmcode_interpreter() when await fails.
Previously, while interpreting a user function, njs_vmcode_interpreter()
might return prematurely when an error happens in await instruction.
This is not correct because the current frame has to be unwound (or
exception caught) first.
The fix is to exit through only 5 appropriate exit points to ensure
proper unwinding.
The patch correctly fixes issue reported in 07ef6c1f04f1 (0.7.3).
This closes #506 issue on Github.
Diffstat (limited to 'test/js/async_exception_in_await.t.js')
-rw-r--r-- | test/js/async_exception_in_await.t.js | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/test/js/async_exception_in_await.t.js b/test/js/async_exception_in_await.t.js new file mode 100644 index 00000000..cc9bc8ab --- /dev/null +++ b/test/js/async_exception_in_await.t.js @@ -0,0 +1,22 @@ +/*--- +includes: [] +flags: [] +---*/ + +var p = new Promise(() => 0); +Object.defineProperty(p, "constructor", {get: () => ({}).a.a}); + +async function g() { + try { + await p; + } catch (e) { + } +} + +function f() { + g(); + + return 42; +} + +assert.sameValue(f(), 42); |