Skip to content

Commit 066b9a9

Browse files
mholtzmanfloating
andcommitted
fix linux SIGTRAP related to power monitor (#1670)
* fix linux SIGTRAP related to power monitor * update tests --------- Co-authored-by: Jordan Muir <jordan@frame.sh>
1 parent b93b8e8 commit 066b9a9

2 files changed

Lines changed: 19 additions & 18 deletions

File tree

main/chains/index.js

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// status = Network Mismatch, Not Connected, Connected, Standby, Syncing
22

3-
const { powerMonitor } = require('electron')
3+
const { app, powerMonitor } = require('electron')
44
const EventEmitter = require('events')
55
const { addHexPrefix } = require('@ethereumjs/util')
66
const { Hardfork } = require('@ethereumjs/common')
@@ -604,19 +604,21 @@ class Chains extends EventEmitter {
604604
})
605605
}
606606

607-
powerMonitor.on('resume', () => {
608-
const activeConnections = Object.keys(this.connections)
609-
.map((type) => Object.keys(this.connections[type]).map((chainId) => `${type}:${chainId}`))
610-
.flat()
607+
app.on('ready', () => {
608+
powerMonitor.on('resume', () => {
609+
const activeConnections = Object.keys(this.connections)
610+
.map((type) => Object.keys(this.connections[type]).map((chainId) => `${type}:${chainId}`))
611+
.flat()
611612

612-
log.info('System resuming, resetting active connections', { chains: activeConnections })
613+
log.info('System resuming, resetting active connections', { chains: activeConnections })
613614

614-
activeConnections.forEach((id) => {
615-
const [type, chainId] = id.split(':')
616-
removeConnection(chainId, type)
617-
})
615+
activeConnections.forEach((id) => {
616+
const [type, chainId] = id.split(':')
617+
removeConnection(chainId, type)
618+
})
618619

619-
updateConnections()
620+
updateConnections()
621+
})
620622
})
621623

622624
store.observer(updateConnections, 'chains:connections')

test/__mocks__/electron.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,13 @@ const dataPaths = {
44
userData: './test/.userData'
55
}
66

7-
const app = {
8-
getVersion: () => '0.1',
9-
getName: () => 'frame-test-app',
10-
getPath: (key) => dataPaths[key]
11-
}
12-
13-
const setDataPath = (key, path) => (dataPaths[key] = path)
7+
const app = new EventEmitter()
8+
app.getVersion = () => '0.1'
9+
app.getName = () => 'frame-test-app'
10+
app.getPath = (key) => dataPaths[key]
1411

1512
const powerMonitor = new EventEmitter()
1613

14+
const setDataPath = (key, path) => (dataPaths[key] = path)
15+
1716
export { app, setDataPath as _setDataPath, powerMonitor }

0 commit comments

Comments
 (0)