Commit c2ac17ad authored by Henrik Skupin's avatar Henrik Skupin
Browse files

Bug 1685454 - [marionette] Enhance retry logic for...

Bug 1685454 - [marionette] Enhance retry logic for getMarionetteCommandsActorProxy for inactive actors. r=marionette-reviewers,jdescottes, a=jcristau

When the window of the current child actor instance is moved
into bfcache the actor doesn't get destroyed. Instead
this.contentWindow will become "null", which means that the
command has to be run again in the active actor instance.

By raising a specific error message in the child actor, the
commands actor proxy can handle that error for its retry logic.

Differential Revision: https://phabricator.services.mozilla.com/D101055
parent 77c73651
......@@ -78,6 +78,10 @@ class MarionetteCommandsChild extends JSWindowActorChild {
}
async receiveMessage(msg) {
if (!this.contentWindow) {
throw new DOMException("Actor is no longer active", "InactiveActor");
}
try {
let result;
......
......@@ -335,8 +335,9 @@ function getMarionetteCommandsActorProxy(browsingContextFn) {
const result = await actor[methodName](...args);
return result;
} catch (e) {
if (e.name !== "AbortError") {
// Only AbortError(s) are retried, let any other error through.
if (!["AbortError", "InactiveActor"].includes(e.name)) {
// Only retry when the JSWindowActor pair gets destroyed, or
// gets inactive eg. when the page is moved into bfcache.
throw e;
}
......@@ -347,10 +348,13 @@ function getMarionetteCommandsActorProxy(browsingContextFn) {
if (++attempts > MAX_ATTEMPTS) {
const browsingContextId = browsingContextFn()?.id;
logger.trace(
`[${browsingContextId}] Query "${methodName}" reached the limit of retry attempts (${MAX_ATTEMPTS})`
`[${browsingContextId}] Querying "${methodName} "` +
`reached the limit of retry attempts (${MAX_ATTEMPTS})`
);
throw e;
}
logger.trace(`Retrying "${methodName}", attempt: ${attempts}`);
}
}
};
......
Supports Markdown
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