Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
xsmith
WebAssembly Sandbox
Commits
8a6b914e
Commit
8a6b914e
authored
Jan 06, 2022
by
Guy Watson
Browse files
Add more fetch-retry logic
parent
e853c37c
Changes
1
Hide whitespace changes
Inline
Side-by-side
puppeteer/load-puppeteer.js
View file @
8a6b914e
...
...
@@ -97,16 +97,22 @@ function crcMemory(wasm_memory){
// Fetch retry function to help chromium fetch the wasm file
// https://dev.to/ycmjason/javascript-fetch-retry-upon-failure-3p6g
const
fetch_retry
=
async
(
url
,
n
)
=>
{
let
response
=
await
fetch
(
url
);
if
(
!
response
.
ok
)
{
if
(
n
===
1
)
{
throw
Error
(
""
+
response
.
status
+
"
:
"
+
response
.
statusText
);
}
else
{
return
await
fetch_retry
(
url
,
n
-
1
);
}
}
else
{
return
response
let
response
;
try
{
response
=
await
fetch
(
url
);
}
catch
(
err
)
{
if
(
n
===
1
)
{
throw
err
;
}
return
await
fetch_retry
(
url
,
n
-
1
);
}
if
(
!
response
.
ok
)
{
if
(
n
===
1
)
{
throw
Error
(
""
+
response
.
status
+
"
:
"
+
response
.
statusText
);
}
return
await
fetch_retry
(
url
,
n
-
1
);
}
return
response
;
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment