chakra-core / chakra-core/ChakraCore
Throw in async function after await is not caught by debugger
- Dominant language
- JavaScript
- Stars
- 9.3k
- Forks
- 1.2k
- PR merge metrics
- No merged PRs in 30d
Description
While debugging is enabled, if one throws an error inside of an async function:
```js
async function f()
{
throw new Error("*munch*");
}
f();
```
Normally, such an error would be intercepted and trigger a breakpoint (`JsDiagDebugEventRuntimeException`):
```
D:\temp>ssj -r error.js
SSj X.X.X Sphere JavaScript debugger (x64)
the powerful symbolic JS debugger for Sphere
(c) 2015-2018 Fat Cerberus
starting 'D:/temp/error.js'... OK.
connecting to 127.0.0.1:1208... OK.
establishing communication... OK.
downloading game information... OK.
engine: miniSphere X.X.X
title: error.js
author: Author Unknown
uncaught: Error: *munch*
at f (@/error.js:4:2)
at Generator.prototype.next (native code)
at Global code (@/error.js:6:1)
-> # 0: f(), at @/error.js:4
4 throw new Error("*munch*");
@/error.js:4 f()
(ssj) l
1 async function f()
2 {
3 //await null;
-> 4 throw new Error("*munch*");
5 }
6 f();
```
However, if one were to uncomment the `await` in the code above, no breakpoint will be triggered and the promise is just silently rejected:
```
D:\temp>ssj -r error.js
SSj X.X.X Sphere JavaScript debugger (x64)
the powerful symbolic JS debugger for Sphere
(c) 2015-2018 Fat Cerberus
starting 'D:/temp/error.js'... OK.
connecting to 127.0.0.1:1208... OK.
establishing communication... OK.
downloading game information... OK.
engine: miniSphere X.X.X
title: error.js
author: Author Unknown
SSj/Ki debug session disconnected normally.
the SSj debugger has been detached.
```
**Update (6/26/2018):**
There are multiple work items here & I wanted to break them out independently. Will leave this open to track getting this to work w/ async/await. The other issues are:
- PR: fixing issue where "uncaught" exceptions in promises wouldn't notify debugger #5328
- Issue: Debugger: Support detecting pending promise reactions for "break on uhandled exceptions" #5371
- Issue: Debugger: Add support for breaking in debugger on unhandled promise rejection #5370
RE async/await, it looks like we'll need to do some work to update byte-code-generation & possibly jit code so that we understand syntactic constructs that result in a "handled" async functions.
Contributor guide
Assessment
This issue has not been assessed yet.