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 authored Sep 26, 2023
1 parent 42663d5 commit a223705
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 26 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 @@ -491,19 +491,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
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@
"@types/zxcvbn": "4.4.1",
"@typescript-eslint/eslint-plugin": "5.54.1",
"@typescript-eslint/parser": "5.54.1",
"electron": "25.8.2",
"electron": "26.2.2",
"electron-builder": "23.6.0",
"electron-devtools-installer": "3.2.0",
"electron-extension-installer": "1.2.0",
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 a223705

Please sign in to comment.