mirror of
https://github.com/dillonkearns/elm-pages-v3-beta.git
synced 2024-12-29 14:56:36 +03:00
Try safeFetch wrapper to handle ENOENT errors if server environment has a filesystem error.
This commit is contained in:
parent
e2297cd52f
commit
0f11b031fb
@ -97,7 +97,7 @@ function lookupOrPerform(portsFile, mode, rawRequest, hasFsAccess, useCache) {
|
||||
} else {
|
||||
try {
|
||||
console.time(`fetch ${request.url}`);
|
||||
const response = await fetch(request.url, {
|
||||
const response = await safeFetch(fetch, request.url, {
|
||||
method: request.method,
|
||||
body: request.body,
|
||||
headers: {
|
||||
@ -241,4 +241,17 @@ function jsonResponse(json) {
|
||||
return { bodyKind: "json", body: json };
|
||||
}
|
||||
|
||||
async function safeFetch(fetch, url, options) {
|
||||
try {
|
||||
return await fetch(url, options);
|
||||
} catch (error) {
|
||||
console.log("@@@safeFetch error", error);
|
||||
if ("code" in error && code === "ENOENT") {
|
||||
return await fetch(url, { cachePath: undefined, ...options });
|
||||
} else {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = { lookupOrPerform };
|
||||
|
Loading…
Reference in New Issue
Block a user