Skip to content

Commit cc8b03a

Browse files
authored
Hook beforeunload to cancel existing requests (#51)
We've been seeing passkeys on desktop Safari getting progressively less reliable, as noted in [this bug](https://bugs.webkit.org/show_bug.cgi?id=273712). My hunch is that there's some sort of browser-wide state getting thrown off if requests (in practice, only conditional) hang around. To be clear, I'm not sure if this will actually work. I haven't witnessed it causing any issues, and it seemed to minorly improve the situation (but the system in question is completely opaque to me, so it's just as likely coincidental) - after testing locally, Safari seemed to be not _completely_ stuck after a couple cycles through. Other than a handful of additional bytes, I don't see much of a downside here.
1 parent bc49d6d commit cc8b03a

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

src/SDK.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ class SDK {
5959
constructor(publicKey: string, host: string = 'https://api.snapauth.app') {
6060
this.apiKey = publicKey
6161
this.host = host
62+
window.addEventListener('beforeunload', this.cancelExistingRequests)
6263
}
6364

6465
get isWebAuthnAvailable() {

0 commit comments

Comments
 (0)