mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-05-23 17:19:37 +02: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:
@@ -49,5 +49,10 @@ function sendBeacon(key, data) {
|
||||
const blob = new Blob([JSON.stringify(data)], {
|
||||
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.
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user