Bug 1571863 Part 2 - Handle failures when communicating with source fronts, and reenable browser_dbg-worker-scopes.js, r=loganfsmyth.

Depends on D50762

Differential Revision: https://phabricator.services.mozilla.com/D50763

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Brian Hackett 2019-10-31 13:55:09 +00:00
Родитель 10ef99e089
Коммит 7665a7d7c0
5 изменённых файлов: 34 добавлений и 20 удалений

Просмотреть файл

@ -73,18 +73,32 @@ async function loadSource(
return result;
}
const actors = getSourceActorsForSource(state, source.id);
if (!actors.length) {
throw new Error("No source actor for loadSource");
// We only need the source text from one actor, but messages sent to retrieve
// the source might fail if the actor has or is about to shut down. Keep
// trying with different actors until one request succeeds.
let response;
const handledActors = new Set();
while (true) {
const actors = getSourceActorsForSource(state, source.id);
const actor = actors.find(({ actor: a }) => !handledActors.has(a));
if (!actor) {
throw new Error("Unknown source");
}
handledActors.add(actor.actor);
try {
telemetry.start(loadSourceHistogram, source);
response = await client.sourceContents(actor);
telemetry.finish(loadSourceHistogram, source);
break;
} catch (e) {
console.warn(`sourceContents failed: ${e}`);
}
}
telemetry.start(loadSourceHistogram, source);
const response = await client.sourceContents(actors[0]);
telemetry.finish(loadSourceHistogram, source);
return {
text: response.source,
contentType: response.contentType || "text/javascript",
text: (response: any).source,
contentType: (response: any).contentType || "text/javascript",
};
}

Просмотреть файл

@ -268,7 +268,7 @@ describe("loadSourceText", () => {
: null;
expect(
content && isRejected(content) && typeof content.value === "string"
? content.value.indexOf("unknown source")
? content.value.indexOf("Unknown source")
: -1
).not.toBe(-1);
});

Просмотреть файл

@ -122,7 +122,7 @@ function lookupThreadFront(thread: string) {
function listThreadFronts() {
const targetList = (Object.values(getTargetsMap()): any);
return targetList.map(target => target.threadFront);
return targetList.map(target => target.threadFront).filter(t => !!t);
}
function forEachThread(iteratee) {
@ -521,10 +521,11 @@ async function getSourceActorBreakableLines({
thread,
actor,
}: SourceActor): Promise<Array<number>> {
const sourceThreadFront = lookupThreadFront(thread);
const sourceFront = sourceThreadFront.source({ actor });
let sourceFront;
let actorLines = [];
try {
const sourceThreadFront = lookupThreadFront(thread);
sourceFront = sourceThreadFront.source({ actor });
actorLines = await sourceFront.getBreakableLines();
} catch (e) {
// Handle backward compatibility
@ -532,10 +533,11 @@ async function getSourceActorBreakableLines({
e.message &&
e.message.match(/does not recognize the packet type getBreakableLines/)
) {
const pos = await sourceFront.getBreakpointPositionsCompressed();
const pos = await (sourceFront: any).getBreakpointPositionsCompressed();
actorLines = Object.keys(pos).map(line => Number(line));
} else if (!e.message || !e.message.match(/Connection closed/)) {
throw e;
} else {
// Other exceptions could be due to the target thread being shut down.
console.warn(`getSourceActorBreakableLines failed: ${e}`);
}
}

Просмотреть файл

@ -160,7 +160,7 @@ skip-if = os == "win"
[browser_dbg-windowless-workers-early-breakpoint.js]
[browser_dbg-worker-exception.js]
[browser_dbg-worker-scopes.js]
skip-if = true #Bug 1456013, Bug 1559547, Bug 1571863
skip-if = (os == 'linux' && debug) || (os == 'linux' && asan) || ccov #Bug 1456013, Bug 1559547
[browser_dbg-event-handler.js]
[browser_dbg-event-breakpoints.js]
[browser_dbg-eval-throw.js]

Просмотреть файл

@ -2,10 +2,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
// This error shows up sometimes when running the test, and while this is a
// strange problem that shouldn't be happening it doesn't prevent the test from
// completing successfully.
PromiseTestUtils.whitelistRejectionsGlobally(/Current state is running/);
PromiseTestUtils.whitelistRejectionsGlobally(/Connection closed/);
function findNode(dbg, text) {
for (let index = 0; ; index++) {