Commit b122da39 authored by gsathya's avatar gsathya Committed by Commit bot

[async await] Fix debug async task event

If the catch prediction machinery in the middle of some async op, we
shouldn't send invalid events to the debugger.

Instead of sending events with an undefined id, we don't send them at
all.

Review-Url: https://codereview.chromium.org/2417093003
Cr-Commit-Position: refs/heads/master@{#40327}
parent 70416a2b
......@@ -158,11 +158,16 @@ function AsyncFunctionPromiseRelease(promise) {
if (DEBUG_IS_ACTIVE) {
// Cancel
var id = GET_PRIVATE(promise, promiseAsyncStackIDSymbol);
%DebugAsyncTaskEvent({
type: "cancel",
id: id,
name: "async function",
});
// Don't send invalid events when catch prediction is turned on in
// the middle of some async operation.
if (!IS_UNDEFINED(id)) {
%DebugAsyncTaskEvent({
type: "cancel",
id: id,
name: "async function",
});
}
// Pop the Promise under construction in an async function on
// from catch prediction stack.
%DebugPopPromise();
......
......@@ -43,6 +43,7 @@ function assertLog(msg) {
function listener(event, exec_state, event_data, data) {
if (event != Debug.DebugEvent.AsyncTaskEvent) return;
try {
if ("Promise.resolve" == event_data.name()) return;
if (base_id < 0)
base_id = event_data.id();
var id = event_data.id() - base_id + 1;
......@@ -73,3 +74,24 @@ resolver();
%RunMicrotasks();
assertNull(exception);
Debug.clearBreakOnUncaughtException();
Debug.setListener(null);
var resolve;
var turnOnListenerPromise = new Promise(r => resolve = r);
async function confused() {
await turnOnListenerPromise;
throw foo
}
confused();
Promise.resolve().then(() => {
Debug.setListener(listener);
Debug.setBreakOnUncaughtException();
resolve();
});
%RunMicrotasks();
assertNull(exception);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment