Skip to content

Commit 2147b0f

Browse files
committed
add apply update timeout
1 parent c5147af commit 2147b0f

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

electron/main.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,18 +138,23 @@ async function createWindow() {
138138
ipcMain.handle('pear:applyUpdate', () => {
139139
const pipe = getWorker(mainWorkerSpecifier)
140140

141-
return new Promise((resolve) => {
141+
return new Promise((resolve, reject) => {
142+
const timeout = setTimeout(() => {
143+
pipe.removeListener('data', onData)
144+
reject(new Error('Timed out waiting for pear:updateApplied'))
145+
}, 30000)
146+
142147
function onData(data) {
143148
const message = data.toString()
144149

145150
if (message === 'pear:updateApplied') {
151+
clearTimeout(timeout)
146152
pipe.removeListener('data', onData)
147153
resolve()
148154
}
149155
}
150156

151157
pipe.on('data', onData)
152-
153158
pipe.write('pear:applyUpdate')
154159
})
155160
})

0 commit comments

Comments
 (0)