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

Improve default seed initialization #1333

Closed
ST-DDT opened this issue Sep 5, 2022 · 3 comments · Fixed by #1334
Closed

Improve default seed initialization #1333

ST-DDT opened this issue Sep 5, 2022 · 3 comments · Fixed by #1334
Assignees
Labels
c: bug Something isn't working good first issue Good for newcomers p: 2-high Fix main branch s: accepted Accepted feature / Confirmed bug

Comments

@ST-DDT
Copy link
Member

ST-DDT commented Sep 5, 2022

To avoid issues like this #1324 (comment) where the faker instance is initialized by multiple threads in parallel (thus using the same timestamp in the seed)

this.gen.initGenrand(new Date().getTime() % 1000000000);

The seed initialization should either take a more precise time source or add a random element (in the hope that this returns a different value per thread).

@ST-DDT ST-DDT added c: bug Something isn't working good first issue Good for newcomers p: 2-high Fix main branch s: accepted Accepted feature / Confirmed bug labels Sep 5, 2022
@ST-DDT ST-DDT added this to the v7 - Current Major milestone Sep 5, 2022
@ST-DDT ST-DDT moved this to Todo in Faker Roadmap Sep 5, 2022
@Shinigami92
Copy link
Member

So like in

seed: number | number[] = Math.ceil(Math.random() * Number.MAX_SAFE_INTEGER)
we could replace it with Math.ceil(Math.random() * Number.MAX_SAFE_INTEGER)

@shraddhafalane
Copy link
Contributor

Would like to work on it

@Shinigami92
Copy link
Member

Would like to work on it

@shraddhafalane Go for it

@Shinigami92 Shinigami92 moved this from Todo to In Progress in Faker Roadmap Sep 7, 2022
Repository owner moved this from In Progress to Done in Faker Roadmap Sep 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c: bug Something isn't working good first issue Good for newcomers p: 2-high Fix main branch s: accepted Accepted feature / Confirmed bug
Projects
No open projects
Status: Done
Development

Successfully merging a pull request may close this issue.

3 participants