50f84564b4
This CL fixes an issue with async stacks. The async task stack is not torn down between page navigations or reloads. The result is that any new async tasks are stacked on top of the old pages async task stack. This was not prominent until now for two reasons: 1) Async tasks created in blink are always finished as long as destructors have time to run. 2) When V8 is terminated while running the micro task queue also all async tasks created for Promises (including `await`) are cleaned up properly. Introducing the stack tagging API made it more common for having unfinished async tasks open outside the MTQ, which left the async task stack non-empty during navigation. This CL fixes this problem by clearing out all the async task and async stack data structures for a context group when that context group is reset. R=bmeurer@chromium.org, victorporof@chromium.org Fixed: chromium:1328785 Change-Id: Iee0c3c4a55f66e643829dae3726dc03c735da1dd Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3666620 Reviewed-by: Benedikt Meurer <bmeurer@chromium.org> Commit-Queue: Simon Zünd <szuend@chromium.org> Cr-Commit-Position: refs/heads/main@{#80741}
48 lines
1.4 KiB
JavaScript
48 lines
1.4 KiB
JavaScript
// Copyright 2022 the V8 project authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
// Flags: --experimental-async-stack-tagging-api
|
|
|
|
const {session, contextGroup, Protocol} = InspectorTest.start('Clear the async stack on navigations');
|
|
|
|
const script = `
|
|
function foo() {
|
|
return console.scheduleAsyncTask("foo", true);
|
|
}
|
|
|
|
function bar(id) {
|
|
console.startAsyncTask(id);
|
|
console.trace(id); // When context is reset, this trace gets broken.
|
|
// no finish
|
|
console.cancelAsyncTask(id);
|
|
}
|
|
|
|
bar(foo());
|
|
`;
|
|
|
|
session.setupScriptMap();
|
|
|
|
(async () => {
|
|
Protocol.Runtime.onConsoleAPICalled(({params}) => {
|
|
InspectorTest.log(`---------- console.${params.type}: ${params.args[0].value} ----------`);
|
|
session.logCallFrames(params.stackTrace.callFrames);
|
|
session.logAsyncStackTrace(params.stackTrace.parent);
|
|
});
|
|
|
|
await Protocol.Runtime.enable();
|
|
await Protocol.Debugger.enable();
|
|
await Protocol.Debugger.setAsyncCallStackDepth({ maxDepth: 128 });
|
|
|
|
contextGroup.addScript(script, 0, 0, 'test.js');
|
|
await Protocol.Debugger.onceScriptParsed();
|
|
|
|
contextGroup.reset();
|
|
|
|
// Run the same script again and make sure that the task stack has been reset.
|
|
contextGroup.addScript(script, 0, 0, 'test.js');
|
|
await Protocol.Debugger.onceScriptParsed();
|
|
|
|
InspectorTest.completeTest();
|
|
})();
|