mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-29 17:23:48 -05:00
Add try/catch around use of navigator.sendBeacon (#5943)
There is a range of historical browser versions where navigator.sendBeacon is available but will throw an error if it's called with an unacceptable mime-typed Blob as the data: https://bugs.chromium.org/p/chromium/issues/detail?id=490015 GitOrigin-RevId: 7b534cb482ba0de920d2e53b9f0afbf3240b20aa
This commit is contained in:
parent
26d5241eaa
commit
33ea150b98
1 changed files with 6 additions and 1 deletions
|
@ -49,5 +49,10 @@ function sendBeacon(key, data) {
|
||||||
const blob = new Blob([JSON.stringify(data)], {
|
const blob = new Blob([JSON.stringify(data)], {
|
||||||
type: 'application/json; charset=UTF-8',
|
type: 'application/json; charset=UTF-8',
|
||||||
})
|
})
|
||||||
navigator.sendBeacon(`/event/${key}`, blob)
|
try {
|
||||||
|
navigator.sendBeacon(`/event/${key}`, blob)
|
||||||
|
} catch (error) {
|
||||||
|
// Ignored. There's a range of browser for which `navigator.sendBeacon` is available but
|
||||||
|
// will throw an error if it's called with an unacceptable mime-typed Blob as the data.
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue