fix: uses the provided sessionId from session options if provided #1737
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.
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 ofSessionOptions
object – capable of carrying asessionId
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):