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) { ...@@ -158,11 +158,16 @@ function AsyncFunctionPromiseRelease(promise) {
if (DEBUG_IS_ACTIVE) { if (DEBUG_IS_ACTIVE) {
// Cancel // Cancel
var id = GET_PRIVATE(promise, promiseAsyncStackIDSymbol); var id = GET_PRIVATE(promise, promiseAsyncStackIDSymbol);
%DebugAsyncTaskEvent({
type: "cancel", // Don't send invalid events when catch prediction is turned on in
id: id, // the middle of some async operation.
name: "async function", if (!IS_UNDEFINED(id)) {
}); %DebugAsyncTaskEvent({
type: "cancel",
id: id,
name: "async function",
});
}
// Pop the Promise under construction in an async function on // Pop the Promise under construction in an async function on
// from catch prediction stack. // from catch prediction stack.
%DebugPopPromise(); %DebugPopPromise();
......
...@@ -43,6 +43,7 @@ function assertLog(msg) { ...@@ -43,6 +43,7 @@ function assertLog(msg) {
function listener(event, exec_state, event_data, data) { function listener(event, exec_state, event_data, data) {
if (event != Debug.DebugEvent.AsyncTaskEvent) return; if (event != Debug.DebugEvent.AsyncTaskEvent) return;
try { try {
if ("Promise.resolve" == event_data.name()) return;
if (base_id < 0) if (base_id < 0)
base_id = event_data.id(); base_id = event_data.id();
var id = event_data.id() - base_id + 1; var id = event_data.id() - base_id + 1;
...@@ -73,3 +74,24 @@ resolver(); ...@@ -73,3 +74,24 @@ resolver();
%RunMicrotasks(); %RunMicrotasks();
assertNull(exception); 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