Skip to content

Commit

Permalink
fix: Keep polling for dev mode server if an exception occurs (#13516)
Browse files Browse the repository at this point in the history
If the server is restarting, fetch can result in Uncaught (in promise) TypeError: Failed to fetch
  • Loading branch information
Artur- committed Apr 13, 2022
1 parent a4e6649 commit cd8b9be
Showing 1 changed file with 13 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,19 @@

const delay = 200;
const poll = () => {
fetch(window.location.href, {headers: {'X-DevModePoll': 'true'}}).then(response => {
if (response.headers.has("X-DevModePending")) {
setTimeout(poll, delay);
} else {
// App ready
document.location.reload();
}
})};
try {
fetch(window.location.href, { headers: { 'X-DevModePoll': 'true' } }).then(response => {
if (response.headers.has("X-DevModePending")) {
setTimeout(poll, delay);
} else {
// App ready
document.location.reload();
}
})
} catch (e) {
setTimeout(poll, delay);
}
};

setTimeout(poll, delay);

Expand Down

0 comments on commit cd8b9be

Please sign in to comment.