Skip to content

Commit

Permalink
fix linux SIGTRAP related to power monitor (#1670)
Browse files Browse the repository at this point in the history
* fix linux SIGTRAP related to power monitor

* update tests

---------

Co-authored-by: Jordan Muir <[email protected]>
  • Loading branch information
mholtzman and floating committed Mar 12, 2024
1 parent b93b8e8 commit 066b9a9
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 18 deletions.
24 changes: 13 additions & 11 deletions main/chains/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// status = Network Mismatch, Not Connected, Connected, Standby, Syncing

const { powerMonitor } = require('electron')
const { app, powerMonitor } = require('electron')
const EventEmitter = require('events')
const { addHexPrefix } = require('@ethereumjs/util')
const { Hardfork } = require('@ethereumjs/common')
Expand Down Expand Up @@ -604,19 +604,21 @@ class Chains extends EventEmitter {
})
}

powerMonitor.on('resume', () => {
const activeConnections = Object.keys(this.connections)
.map((type) => Object.keys(this.connections[type]).map((chainId) => `${type}:${chainId}`))
.flat()
app.on('ready', () => {
powerMonitor.on('resume', () => {
const activeConnections = Object.keys(this.connections)
.map((type) => Object.keys(this.connections[type]).map((chainId) => `${type}:${chainId}`))
.flat()

log.info('System resuming, resetting active connections', { chains: activeConnections })
log.info('System resuming, resetting active connections', { chains: activeConnections })

activeConnections.forEach((id) => {
const [type, chainId] = id.split(':')
removeConnection(chainId, type)
})
activeConnections.forEach((id) => {
const [type, chainId] = id.split(':')
removeConnection(chainId, type)
})

updateConnections()
updateConnections()
})
})

store.observer(updateConnections, 'chains:connections')
Expand Down
13 changes: 6 additions & 7 deletions test/__mocks__/electron.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@ const dataPaths = {
userData: './test/.userData'
}

const app = {
getVersion: () => '0.1',
getName: () => 'frame-test-app',
getPath: (key) => dataPaths[key]
}

const setDataPath = (key, path) => (dataPaths[key] = path)
const app = new EventEmitter()
app.getVersion = () => '0.1'
app.getName = () => 'frame-test-app'
app.getPath = (key) => dataPaths[key]

const powerMonitor = new EventEmitter()

const setDataPath = (key, path) => (dataPaths[key] = path)

export { app, setDataPath as _setDataPath, powerMonitor }

0 comments on commit 066b9a9

Please sign in to comment.