mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-30 16:18:07 +01:00
8eb91e89bf
Fixes #791 It was possible for two requests to have the same ID, causing a crash and loss of StreamProvider connection. This new id generation strategy creates a random ID, and increments it for each request. In case the id generator is included from two different processes, I'm initializing the counter at a random number, and rolling it over a large number when it gets too big.
10 lines
188 B
JavaScript
10 lines
188 B
JavaScript
const MAX = 1000000000
|
|
|
|
let idCounter = Math.round( Math.random() * MAX )
|
|
function createRandomId() {
|
|
idCounter = idCounter % MAX
|
|
return idCounter++
|
|
}
|
|
|
|
module.exports = createRandomId
|