-
-
Notifications
You must be signed in to change notification settings - Fork 130
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed exception thrown while machine id generation.
Machine ID generation was throwing an exception which was looping and causing `Maximum call stack size exceeded`
- Loading branch information
1 parent
47ca4c3
commit b32b57b
Showing
9 changed files
with
57 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,24 @@ | ||
import { machineId } from 'node-machine-id'; | ||
import { settingsStorage } from './storageHelper'; | ||
import { v6 as uuidv6 } from 'uuid'; | ||
|
||
export async function getMachineId() { | ||
const settings = settingsStorage.getItems(['machineId']); | ||
import { identifierStorage } from './storageHelper'; | ||
import { isEmpty } from '../utils/funcs'; | ||
|
||
if (!settings?.machineId) { | ||
const _machineId = await machineId(); | ||
export function getMachineId() { | ||
try { | ||
const settings = identifierStorage.getItems(['machineId']); | ||
|
||
settingsStorage.setItems({ | ||
machineId: _machineId, | ||
}); | ||
if (!settings?.machineId || isEmpty(settings?.machineId)) { | ||
const _machineId = uuidv6(); | ||
|
||
return _machineId; | ||
} | ||
identifierStorage.setItems({ | ||
machineId: _machineId, | ||
}); | ||
|
||
return _machineId; | ||
} | ||
|
||
return settings.machineId; | ||
return settings.machineId; | ||
} catch (e) { | ||
console.error(`Unable to find machineId. Error: ${e}`); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
import { PATHS } from '../constants/paths'; | ||
import Storage from '../classes/Storage'; | ||
|
||
const { settingsFile } = PATHS; | ||
const { settingsFile, identifierFile } = PATHS; | ||
|
||
export const settingsStorage = new Storage(settingsFile); | ||
export const identifierStorage = new Storage(identifierFile, true); | ||
|
||
export const settingsStorage = new Storage(settingsFile, false); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters