Prefetch IDE resolve query

Summary:
To avoid showing the Ugly spinner in the context menu as well as a better UX we prefetch the IDE resolved path. It was important to limit the concurrency of the running arc jobs otherwise lots of bad things happen and the whole machine stalls out.

The general idea is as the frame comes off the wire we send them to react query to prefetch. by setting the cache time sending the same key twice will not result in 2 fetches, so we dont need to worry about deduplication on our side

Reviewed By: antonk52

Differential Revision: D47210292

fbshipit-source-id: 4a1d8efdfae754c1a73c6a868b02d1f3a0a5b567
This commit is contained in:
Luke De Feo
2023-07-10 09:22:39 -07:00
committed by Facebook GitHub Bot
parent 5aa0ddb0a3
commit 993413c5f2
6 changed files with 54 additions and 19 deletions

View File

@@ -30,9 +30,9 @@ import {
UIState,
} from './types';
import {Draft} from 'immer';
import {QueryClient, setLogger} from 'react-query';
import {tracker} from './tracker';
import {getStreamInterceptor} from './fb-stubs/StreamInterceptor';
import {prefetchSourceFileLocation} from './components/fb-stubs/IDEContextMenu';
type LiveClientState = {
snapshotInfo: SnapshotInfo | null;
@@ -265,6 +265,7 @@ export function plugin(client: PluginClient<Events>) {
}
applyFrameworkEvents(frameScan);
return true;
} catch (error) {
pendingData.frame = frameScan;
@@ -339,6 +340,12 @@ export function plugin(client: PluginClient<Events>) {
checkFocusedNodeStillActive(uiState, nodesAtom.get());
}
setTimeout(() => {
//let react render, this can happen async
for (const node of nodes.values()) {
prefetchSourceFileLocation(node);
}
}, 0);
}
client.onMessage('subtreeUpdate', (subtreeUpdate) => {
processFrame({
@@ -350,8 +357,6 @@ export function plugin(client: PluginClient<Events>) {
});
client.onMessage('frameScan', processFrame);
const queryClient = new QueryClient({});
return {
rootId,
uiState,
@@ -362,7 +367,6 @@ export function plugin(client: PluginClient<Events>) {
metadata,
perfEvents,
setPlayPause,
queryClient,
os,
};
}
@@ -503,16 +507,3 @@ const HighlightTime = 300;
export {Component} from './components/main';
export * from './types';
setLogger({
log: (...args) => {
console.log(...args);
},
warn: (...args) => {
console.warn(...args);
},
error: (...args) => {
//downgrade react query network errors to warning so they dont get sent to scribe
console.warn(...args);
},
});