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

fix: uses the provided sessionId from session options if provided #1737

Conversation

jesperstarkar
Copy link
Contributor

@jesperstarkar jesperstarkar commented Jan 31, 2025

Bugfix (one-line fix)

Fixes issue #1180

There is an implicit contract when creating a new session that you can set the sessionId by providing this optional parameter on the createSession() options-paramter object.

The implementation of createSession() ignores this, and always creates a new uuidv4 as the sessionId.

This PR changes that to prioritize the supplied options.sessionId string - if provided.

However, there might be a bigger problem to address, as the loadSession() implementation has a potential "footgun" problem: it both accepts an explicit sessionId function parameter (which will take effect), as well as the same kind of SessionOptions object – capable of carrying a sessionId property too, which will never be used. Mentioning this as there might be a better an more universal refactoring needed to solve both this corners.

Not sure about the coding-style in my commit. There might be valid opinions to steer clear of this level of optional chaining.

Checklist (if applicable):

Copy link

google-cla bot commented Jan 31, 2025

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@jesperstarkar jesperstarkar force-pushed the fix/respect-sessionid-when-creating-session branch from 2ff65d3 to 1389cf1 Compare February 3, 2025 09:57
@pavelgj pavelgj merged commit 4b21318 into firebase:main Feb 3, 2025
6 checks passed
@jesperstarkar jesperstarkar deleted the fix/respect-sessionid-when-creating-session branch February 3, 2025 22:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants