Commit 87b997b
authored
feat(auth): add deprecation notice to
If you pass in an async function to `onAuthStateChange` and call a
Supabase Client API, it's very likely you'll end up with a deadlock.
Example:
```typescript
supabase.auth.onAuthStateChange(async () => {
await supabase.auth.getClaims()
})
```
This is because:
- `onAuthStateChange` runs inside an exclusive lock
- If you call another API that tries to acquire the exclusive lock, the
initial call will never finish, thereby never releasing the first lock,
and no other Auth API can be called (across all tabs)
Multiple attempts were made to detect these situations but it's not easy
as async functions don't track execution context in all environments
properly.
This change adds a deprecation notice if the callback is an async
function to discourage folks from using it, and hopefully make it a bit
faster to realize why suddenly everything is frozen.onAuthStateChange with async function (#1580)1 parent 428a7ff commit 87b997b
1 file changed
+22
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2078 | 2078 | | |
2079 | 2079 | | |
2080 | 2080 | | |
| 2081 | + | |
| 2082 | + | |
2081 | 2083 | | |
2082 | 2084 | | |
| 2085 | + | |
| 2086 | + | |
| 2087 | + | |
| 2088 | + | |
| 2089 | + | |
| 2090 | + | |
| 2091 | + | |
| 2092 | + | |
| 2093 | + | |
| 2094 | + | |
| 2095 | + | |
| 2096 | + | |
| 2097 | + | |
| 2098 | + | |
| 2099 | + | |
| 2100 | + | |
| 2101 | + | |
| 2102 | + | |
| 2103 | + | |
| 2104 | + | |
2083 | 2105 | | |
2084 | 2106 | | |
2085 | 2107 | | |
| |||
0 commit comments