feat: steal the auth lock if it was not completed in 10s (#39868)

This commit is contained in:
Stojan Dimitrovski authored and GitHub committed 2025-10-27 18:45:21 +01:00
1 parent 482e477d00
commit 83dffaeddd
1 file changed
+23 -1
+23 -1
View File
@@ -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)