Repository navigation
fix(auth): defer init-time notifications until initializePromise resolves - #2498
Merged
Merged
Conversation
@supabase/auth-js
@supabase/functions-js
@supabase/postgrest-js
@supabase/realtime-js
@supabase/storage-js
@supabase/supabase-js
commit: |
mandarini
force-pushed
the
fix/init-notify-deadlock
branch
from
July 6, 2026 14:40
3861d3a to
0e5bd93
Compare
spydon
approved these changes
Jul 6, 2026
This was referenced Jul 7, 2026
mandarini
pushed a commit
to supabase/ssr
that referenced
this pull request
Jul 7, 2026
This PR updates `@supabase/supabase-js` to v2.110.1. **Source**: supabase-js-stable-release --- ## Release Notes ## v2.110.1 ## 2.110.1 (2026-07-07) ### 🩹 Fixes - **auth:** defer init-time notifications until initializePromise resolves ([#2498](supabase/supabase-js#2498)) - **realtime:** suppress disconnected status from onHeartbeat consumers ([#2496](supabase/supabase-js#2496)) ### ❤️ Thank You - Katerina Skroumpelou @mandarini This PR was created automatically. Co-authored-by: supabase-workflow-trigger[bot] <266661614+supabase-workflow-trigger[bot]@users.noreply.github.com>
mandarini
pushed a commit
to supabase/supabase
that referenced
this pull request
Jul 7, 2026
This PR updates @supabase/*-js libraries to version 2.110.1. **Source**: supabase-js-stable-release **Changes**: - Updated @supabase/supabase-js to 2.110.1 - Updated @supabase/auth-js to 2.110.1 - Updated @supabase/realtime-js to 2.110.1 - Updated @supabase/postgest-js to 2.110.1 - Refreshed pnpm-lock.yaml --- ## Release Notes ## v2.110.1 ## 2.110.1 (2026-07-07) ### 🩹 Fixes - **auth:** defer init-time notifications until initializePromise resolves ([#2498](supabase/supabase-js#2498)) - **realtime:** suppress disconnected status from onHeartbeat consumers ([#2496](supabase/supabase-js#2496)) ### ❤️ Thank You - Katerina Skroumpelou @mandarini ## v2.110.0 ## 2.110.0 (2026-06-30) ### 🚀 Features - **repo:** drop Node.js 20 support ([#2482](supabase/supabase-js#2482)) ### ❤️ Thank You - Katerina Skroumpelou @mandarini ## v2.109.0 ## 2.109.0 (2026-06-30) ### 🚀 Features - **auth:** add custom_claims_allowlist to custom providers admin API ([#2473](supabase/supabase-js#2473)) - **realtime:** add postgres_changes filter builder, new operators and select ([#2463](supabase/supabase-js#2463)) - **storage:** expose purgeCache for buckets and single objects ([#2429](supabase/supabase-js#2429)) ### 🩹 Fixes - **functions:** honor a caller's Content-Type override regardless of casing ([#2455](supabase/supabase-js#2455)) - **realtime:** pin @supabase/phoenix and browser test CDN deps ([#2457](supabase/supabase-js#2457)) - **realtime:** add replication connection system message option ([#2470](supabase/supabase-js#2470)) - **storage:** keep sortBy defaults when list() is given a partial sortBy ([#2454](supabase/supabase-js#2454)) ### ❤️ Thank You - Anubhav Anand @i-anubhav-anand - Cemal Kılıç @cemalkilic - Claude Opus 4.8 (1M context) - Filipe Cabaço @filipecabaco - Katerina Skroumpelou @mandarini - Lenny - Rodrigo Mansueli @mansueli This PR was created automatically. Co-authored-by: supabase-workflow-trigger[bot] <266661614+supabase-workflow-trigger[bot]@users.noreply.github.com>
This was referenced Jul 13, 2026
Closed
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
What changed?
Three changes to
GoTrueClientin@supabase/auth-js:_pendingInitNotificationsfield -- an array that is non-null only whileinitialize()is running, used as a deferred notification queue._notifyAllSubscribers(): when the queue is open (non-null), notifications are enqueued instead of fired immediately.initialize()to open the queue before_initialize()runs, then flush it in order afterinitializePromiseresolves.Three regression tests were added to
GoTrueClient.test.tscovering theSIGNED_INpath (valid session at boot), theTOKEN_REFRESHEDpath (near-expiry session that triggers a proactive refresh), and an assertion thatinitializePromiseis already resolved when the callback runs.Why was this change needed?
During
initialize(),_recoverAndRefresh()fires auth events (SIGNED_IN,TOKEN_REFRESHED,SIGNED_OUT) beforeinitializePromisehas resolved. Every public auth method --getSession(),getUser(),signOut(),updateUser(),refreshSession()-- gates onawait this.initializePromise. If anonAuthStateChangecallback called any of those methods, a permanent circular deadlock formed:getSession()getSession()awaitsinitializePromiseinitializePromiseawaits_initialize()_initialize()awaits_notifyAllSubscribers()_notifyAllSubscribers()awaits the callbackOnce stuck,
initializePromisenever resolves for the lifetime of the client. Because a new client is constructed on each page load and finds the same valid session in storage, the hang survives full reloads -- which made it appear persistent. This also causedsignInWithPasswordto hang after a successful 200 response, because it firesSIGNED_INthrough the same notify path.The lockless refactor in v2.107.0 (PR #2392) resolved the
navigator.locks-based deadlock but left this separateinitializePromisecircular dependency intact. It manifested most reliably on iOS PWA, where sessions persist across reloads and the stored-session boot path (which triggersSIGNED_INduring init) is the common case.The fix defers all init-time notifications until after
initializePromiseis resolved, so callbacks can call any public auth method safely.Closes #2491
Screenshots/Examples
Before the fix --
initialize()would never return:After the fix,
initialize()completes andgetSession()inside the callback works correctly.Breaking changes
initialize()still waits for all init-time callbacks to complete before returning. Event ordering is preserved. The only behavioral difference is thatgetSession()and other public methods now resolve inside a callback instead of deadlocking.Checklist
<type>(<scope>): <description>pnpm nx formatto ensure consistent code formattingAdditional notes
The guard in
_notifyAllSubscribers()is the single interception point that covers all four call sites in_recoverAndRefresh()without modifying each one individually. The_pendingInitNotificationsfield isnullat all times except during an activeinitialize()call, so there is no behavior change for any notification fired outside of initialization.