mirror of
https://github.com/supabase/supabase.git
synced 2026-10-06 01:45:10 +03:00
feat: steal the auth lock if it was not completed in 10s (#39868)
This commit is contained in:
1 parent
482e477d00
commit
83dffaeddd
1 file changed
+23
-1
@@ -144,10 +144,32 @@ async function debuggableNavigatorLock<R>(
|
||||
}
|
||||
|
||||
console.error(
|
||||
`Waited for over 10s to acquire an Auth client lock`,
|
||||
`Waited for over 10s to acquire an Auth client lock, will steal the lock to unblock`,
|
||||
await navigator.locks.query(),
|
||||
stackException
|
||||
)
|
||||
|
||||
// quickly steal the lock and release it so that others can acquire it,
|
||||
// while leaving the code that was holding it to continue running
|
||||
navigator.locks
|
||||
.request(
|
||||
name,
|
||||
{
|
||||
steal: true,
|
||||
},
|
||||
async () => {
|
||||
await new Promise((accept) => {
|
||||
setTimeout(accept, 0)
|
||||
})
|
||||
|
||||
console.error('Lock was stolen and now released', stackException)
|
||||
}
|
||||
)
|
||||
.catch((e: any) => {
|
||||
if (captureException) {
|
||||
captureException(e)
|
||||
}
|
||||
})
|
||||
})()
|
||||
}, 10000)
|
||||
|
||||
|
||||
Reference in new issue
Block a user