Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: consider session expired with margin on getSession() without auto refresh #1027

Merged
merged 1 commit into from
Jan 21, 2025

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants