Skip to content

Commit

Permalink
fix: add random number to db id seed (#276)
Browse files Browse the repository at this point in the history
Co-authored-by: Rory Jennings <rory.jennings@nexusmods.com>
  • Loading branch information
themagickoala and Rory Jennings authored Oct 7, 2023
1 parent a39b026 commit 77d2263
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/db/Database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export type DatabaseEventsMap = {
}

let callOrder = 0
const seed = Math.random() * 10_000_000;

export class Database<Dictionary extends ModelDictionary> {
public id: string
Expand Down Expand Up @@ -72,7 +73,7 @@ export class Database<Dictionary extends ModelDictionary> {
private generateId() {
const { stack } = new Error()
const callFrame = stack?.split('\n')[4]
const salt = `${callOrder}-${callFrame?.trim()}`
const salt = `${callOrder}-${callFrame?.trim()}-${Math.round(seed)}`
return md5(salt)
}

Expand Down

0 comments on commit 77d2263

Please sign in to comment.