fetchFromNetworkCache() — react Function Reference
Architecture documentation for the fetchFromNetworkCache() function in fetchFileWithCaching.js from the react codebase.
Entity Profile
Dependency Diagram
graph TD 07cdcb7e_d08b_cea3_7731_755f443b7d3a["fetchFromNetworkCache()"] 8128576f_0171_0141_7371_cfb7e102597e["fetchFileWithCaching.js"] 07cdcb7e_d08b_cea3_7731_755f443b7d3a -->|defined in| 8128576f_0171_0141_7371_cfb7e102597e 8288643d_dc4e_6c27_0a62_597f4b057516["debugLog()"] 07cdcb7e_d08b_cea3_7731_755f443b7d3a -->|calls| 8288643d_dc4e_6c27_0a62_597f4b057516 d8e27196_681b_1e9c_e0ef_5d96abe58b82["fetchFromPage()"] 07cdcb7e_d08b_cea3_7731_755f443b7d3a -->|calls| d8e27196_681b_1e9c_e0ef_5d96abe58b82 style 07cdcb7e_d08b_cea3_7731_755f443b7d3a fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/react-devtools-extensions/src/main/fetchFileWithCaching.js lines 14–79
const fetchFromNetworkCache = (url, resolve, reject) => {
// Debug ID allows us to avoid re-logging (potentially long) URL strings below,
// while also still associating (potentially) interleaved logs with the original request.
let debugID = null;
if (__DEBUG__) {
debugID = debugIDCounter++;
debugLog(`[main] fetchFromNetworkCache(${debugID})`, url);
}
chrome.devtools.network.getHAR(harLog => {
for (let i = 0; i < harLog.entries.length; i++) {
const entry = harLog.entries[i];
if (url !== entry.request.url) {
continue;
}
debugLog(
`[main] fetchFromNetworkCache(${debugID}) Found matching URL in HAR`,
url,
);
if (entry.getContent != null) {
entry.getContent(content => {
if (content) {
debugLog(
`[main] fetchFromNetworkCache(${debugID}) Content retrieved`,
);
resolve(content);
} else {
debugLog(
`[main] fetchFromNetworkCache(${debugID}) Invalid content returned by getContent()`,
content,
);
// Edge case where getContent() returned null; fall back to fetch.
fetchFromPage(url, resolve, reject);
}
});
} else {
const content = entry.response.content.text;
if (content != null) {
debugLog(
`[main] fetchFromNetworkCache(${debugID}) Content retrieved`,
);
resolve(content);
} else {
debugLog(
`[main] fetchFromNetworkCache(${debugID}) Invalid content returned from entry.response.content`,
content,
);
fetchFromPage(url, resolve, reject);
}
}
}
debugLog(
`[main] fetchFromNetworkCache(${debugID}) No cached request found in getHAR()`,
);
// No matching URL found; fall back to fetch.
fetchFromPage(url, resolve, reject);
});
};
Domain
Subdomains
Source
Frequently Asked Questions
What does fetchFromNetworkCache() do?
fetchFromNetworkCache() is a function in the react codebase, defined in packages/react-devtools-extensions/src/main/fetchFileWithCaching.js.
Where is fetchFromNetworkCache() defined?
fetchFromNetworkCache() is defined in packages/react-devtools-extensions/src/main/fetchFileWithCaching.js at line 14.
What does fetchFromNetworkCache() call?
fetchFromNetworkCache() calls 2 function(s): debugLog, fetchFromPage.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free