Skip to content

Commit

Permalink
Bug 1619622 - Stop fetching the sources twice. r=jdescottes,jlast
Browse files Browse the repository at this point in the history
We already do that from actions, once per added thread.
Only the timing may be different.

Differential Revision: https://phabricator.services.mozilla.com/D72686
  • Loading branch information
ochameau committed May 13, 2020
1 parent 80bb55f commit 8919127
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 21 deletions.
22 changes: 12 additions & 10 deletions devtools/client/debugger/src/actions/threads.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,25 @@ import {
getSourceActorsForThread,
} from "../selectors";

function addThreads(
async function addThreads(
{ dispatch, client, getState }: ThunkArgs,
addedThreads: ThreadList
) {
const cx = getContext(getState());
dispatch(({ type: "INSERT_THREADS", cx, threads: addedThreads }: Action));

// Fetch the sources and install breakpoints on any new workers.
// NOTE: This runs in the background and fails quietly because it is
// pretty easy for sources to throw during the fetch if their thread
// shuts down, which would cause test failures.
for (const thread of addedThreads) {
client
.fetchThreadSources(thread.actor)
.then(sources => dispatch(newGeneratedSources(sources)))
.catch(e => console.error(e));
}
await Promise.all(addedThreads.map(async thread => {
try {
const sources = await client.fetchThreadSources(thread.actor);
await dispatch(newGeneratedSources(sources));
} catch (e) {
// NOTE: This fails quietly because it is pretty easy for sources to
// throw during the fetch if their thread shuts down,
// which would cause test failures.
console.error(e);
}
}));
}

function removeThreads(
Expand Down
11 changes: 0 additions & 11 deletions devtools/client/debugger/src/client/firefox.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,17 +86,6 @@ async function onTargetAvailable({
targetFront.isWebExtension
);

// Fetch the sources for all the targets
//
// In Firefox, we need to initially request all of the sources. This
// usually fires off individual `newSource` notifications as the
// debugger finds them, but there may be existing sources already in
// the debugger (if it's paused already, or if loading the page from
// bfcache) so explicity fire `newSource` events for all returned
// sources.
const sources = await clientCommands.fetchSources();
await actions.newGeneratedSources(sources);

await actions.addTarget(targetFront);

await clientCommands.checkIfAlreadyPaused();
Expand Down

0 comments on commit 8919127

Please sign in to comment.