Skip to content
This repository was archived by the owner on Oct 10, 2025. It is now read-only.

Conversation

@hf
Copy link
Contributor

@hf hf commented Jan 21, 2025

When autoRefreshToken is off (or when a tab is in the background) but getSession() is called -- such as in an active Realtime channel, getSession() might return a JWT which will expire while the message is travelling over the internet. There is one confirmed case of this happening.

This PR adjusts this using the established EXPIRY_MARGIN_MS constant (which only applies on initial initialization of the client). The constant's value is brought in line with the autoRefreshToken ticks which run every 30 seconds and refreshing is attempted 3 ticks prior to the session expiring.

This means that JWTs with an expiry value less than 90s will always refresh the session; which is acceptable.

@hf hf merged commit 80f88e4 into master Jan 21, 2025
7 checks passed
@hf hf deleted the hf/session-expired-with-margin-no-autorefresh branch January 21, 2025 21:27
hf pushed a commit that referenced this pull request Jan 23, 2025
🤖 I have created a release *beep* *boop*
---


##
[2.68.0](v2.67.3...v2.68.0)
(2025-01-21)


### Features

* consider session expired with margin on getSession() without auto
refresh ([#1027](#1027))
([80f88e4](80f88e4))


### Bug Fixes

* remove `internal-types.ts`
([#1014](#1014))
([28ead89](28ead89))
* update docs to add scrypt
([#1012](#1012))
([1225239](1225239))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
mandarini pushed a commit to supabase/supabase-js that referenced this pull request Oct 2, 2025
🤖 I have created a release *beep* *boop*
---


##
[2.68.0](supabase/auth-js@v2.67.3...v2.68.0)
(2025-01-21)


### Features

* consider session expired with margin on getSession() without auto
refresh ([#1027](supabase/auth-js#1027))
([a51dbb0](supabase/auth-js@a51dbb0))


### Bug Fixes

* remove `internal-types.ts`
([#1014](supabase/auth-js#1014))
([902ec1d](supabase/auth-js@902ec1d))
* update docs to add scrypt
([#1012](supabase/auth-js#1012))
([0dc969a](supabase/auth-js@0dc969a))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants