Fix PR CI and guard resume relay during shutdown

Co-authored-by: Orca <help@stably.ai>
This commit is contained in:
Jinwoo-H
2026-07-03 16:36:44 -04:00
co-authored by Orca
parent 2e9830da66
commit a2037c8aa4
3 changed files with 19 additions and 3 deletions
+3 -2
View File
@@ -647,10 +647,11 @@ describe('CdpWsProxy', () => {
})
it('does not register a PDF stream when the client disconnects mid-print', async () => {
let resolvePrint: (buf: Buffer) => void = () => {}
type PrintToPdfData = Awaited<ReturnType<typeof mock.webContents.printToPDF>>
let resolvePrint: (buf: PrintToPdfData) => void = () => {}
mock.webContents.printToPDF.mockImplementationOnce(
() =>
new Promise<Buffer>((resolve) => {
new Promise<PrintToPdfData>((resolve) => {
resolvePrint = resolve
})
)
+15
View File
@@ -2822,6 +2822,7 @@ describe('createMainWindow', () => {
invalidate: vi.fn(),
setWindowOpenHandler: vi.fn(),
send: vi.fn(),
isDestroyed: vi.fn(() => false),
id: 1
}
const instance = {
@@ -2883,6 +2884,20 @@ describe('createMainWindow', () => {
expect(webContents.invalidate).not.toHaveBeenCalled()
})
it('does not send the resume event once webContents is destroyed', () => {
const { webContents } = setupResumeWindow()
createMainWindow(null)
const onResume = getPowerResumeListener()
webContents.isDestroyed.mockReturnValue(true)
webContents.send.mockClear()
webContents.invalidate.mockClear()
onResume()
expect(webContents.send).not.toHaveBeenCalled()
expect(webContents.invalidate).not.toHaveBeenCalled()
})
it('removes the powerMonitor resume listener when the window closes', () => {
const { windowHandlers } = setupResumeWindow()
createMainWindow(null)
+1 -1
View File
@@ -345,7 +345,7 @@ export function createMainWindow(
// run. Relay powerMonitor resume explicitly (supported on mac/win/linux)
// and force a repaint so stale compositor surfaces recover too.
const onSystemResume = (): void => {
if (mainWindow.isDestroyed()) {
if (mainWindow.isDestroyed() || mainWindow.webContents.isDestroyed?.() === true) {
return
}
forceRepaint(mainWindow)