mirror of
https://github.com/hanzoai/react.git
synced 2026-09-24 17:02:27 +00:00
Add performance marksf or individual fetch() requests (#22176)
This commit is contained in:
@@ -451,6 +451,10 @@ function extractAndLoadSourceMaps(
|
||||
}
|
||||
|
||||
function fetchFile(url: string): Promise<string> {
|
||||
if (__PERFORMANCE_PROFILE__) {
|
||||
mark('fetchFile("' + url + '")');
|
||||
}
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
fetch(url).then(
|
||||
response => {
|
||||
@@ -458,18 +462,27 @@ function fetchFile(url: string): Promise<string> {
|
||||
response
|
||||
.text()
|
||||
.then(text => {
|
||||
if (__PERFORMANCE_PROFILE__) {
|
||||
measure('fetchFile("' + url + '")');
|
||||
}
|
||||
resolve(text);
|
||||
})
|
||||
.catch(error => {
|
||||
if (__DEBUG__) {
|
||||
console.log(`fetchFile() Could not read text for url "${url}"`);
|
||||
}
|
||||
if (__PERFORMANCE_PROFILE__) {
|
||||
measure('fetchFile("' + url + '")');
|
||||
}
|
||||
reject(null);
|
||||
});
|
||||
} else {
|
||||
if (__DEBUG__) {
|
||||
console.log(`fetchFile() Got bad response for url "${url}"`);
|
||||
}
|
||||
if (__PERFORMANCE_PROFILE__) {
|
||||
measure('fetchFile("' + url + '")');
|
||||
}
|
||||
reject(null);
|
||||
}
|
||||
},
|
||||
@@ -477,6 +490,9 @@ function fetchFile(url: string): Promise<string> {
|
||||
if (__DEBUG__) {
|
||||
console.log(`fetchFile() Could not fetch file: ${error.message}`);
|
||||
}
|
||||
if (__PERFORMANCE_PROFILE__) {
|
||||
measure('fetchFile("' + url + '")');
|
||||
}
|
||||
reject(null);
|
||||
},
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user