Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

hashchange: Handle when history object has been marked dead.

Alex Vandiverd0a8ae0c87c9
diff --git a/web/src/hashchange.js b/web/src/hashchange.js
index 7acfcbd8486..15a59468346 100644
--- a/web/src/hashchange.js
+++ b/web/src/hashchange.js
@@ -57,8 +57,17 @@ function set_hash(hash) {
}
if (history.pushState) {
const url = get_full_url(hash);
- history.pushState(null, null, url);
- browser_history.update_web_public_hash(hash);
+ try {
+ history.pushState(null, null, url);
+ browser_history.update_web_public_hash(hash);
+ } catch (error) {
+ if (error instanceof TypeError) {
+ // The window has been destroyed and the history object has been marked dead, so cannot
+ // be updated. Silently do nothing, since there's nothing we can do.
+ } else {
+ throw error;
+ }
+ }
} else {
blueslip.warn("browser does not support pushState");
window.location.hash = hash;