-
-
Notifications
You must be signed in to change notification settings - Fork 723
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: default session id in frontend api #5083
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
1 Ignored Deployment
|
src/lib/services/proxy-service.ts
Dismissed
@@ -74,12 +74,19 @@ | |||
const client = await this.clientForProxyToken(token); | |||
const definitions = client.getFeatureToggleDefinitions() || []; | |||
|
|||
const sessionId = context.sessionId || String(Math.random()); |
Check failure
Code scanning / CodeQL
Insecure randomness High
Math.random()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we're not doing cryptography here
.map((feature) => ({ | ||
name: feature.name, | ||
enabled: Boolean(feature.enabled), | ||
variant: client.forceGetVariant(feature.name, context), | ||
variant: client.getVariant(feature.name, { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we don't have to use forceGetVariant anymore. Since we have sessionId we don't have to care how getVariant is implemented locally.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh awesome! This LGTM
Guessing a test is borderline impossible here? I think that's okay, this is simple enough
@sighphyre I can think of a property based test or run a regular test 50 times and verify some properties. It will be more work than the change itself but maybe it's worth the effort. |
Yeah, it may be a lot of work. I also think it may be worth it. A prop test would be awesome. We've done some "run this 10K times and poke at the statistics" tests before, they have been useful but they have drawbacks Either way, I'm not going to block this for not having one of those. I still think LGTM, I'll leave it up to you if you want to that now, later or never |
About the changes
What problem are we solving?
Solution:
Important files
Discussion points
Is Math.random() good enough?