Skip to content

Commit

Permalink
fix: handle 'node-machine-id' failures #2885
Browse files Browse the repository at this point in the history
Julusian committed Jun 3, 2024
1 parent 9bea55a commit 71f0258
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion companion/lib/Data/CloudDatabase.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
import { v4 } from 'uuid'
import DataStoreBase from './StoreBase.js'
import nodeMachineId from 'node-machine-id'

function generateMachineId() {
try {
return nodeMachineId.machineIdSync(true)
} catch (e) {
// The nodeMachineId call can fail if the machine has stricter security that blocks regedit
// If that happens, fallback to a uuid, which while not stable, is better than nothing
return v4()
}
}

/**
* The class that manages the applications's cloud config database
*
@@ -29,7 +40,7 @@ class CloudDatabase extends DataStoreBase {
* @access protected
*/
static Defaults = {
uuid: nodeMachineId.machineIdSync(true),
uuid: generateMachineId(),
auth: {
token: '',
user: '',

0 comments on commit 71f0258

Please sign in to comment.