Skip to content

Commit dc91129

Browse files
committed
fix: electron crashes with SIGABRT on quit
It looks like if we don't close the chokidar watchers before exit, the electron main process dies with SIGABRT.
1 parent db041bc commit dc91129

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

plugins/plugin-codeflare/src/tray/watchers/profile/list.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,15 @@ export default class ProfileWatcher {
3232
private readonly updateFn: UpdateFunction,
3333
private readonly profilesPath: string,
3434
private readonly watcher = chokidar.watch(profilesPath, { depth: 1 })
35-
) {}
35+
) {
36+
// we need to close the chokidar watcher before exit, otherwise
37+
// electron-main dies with SIGABRT
38+
import("electron").then((_) =>
39+
_.app.on("will-quit", async () => {
40+
await this.watcher.close()
41+
})
42+
)
43+
}
3644

3745
/** Initialize `this._profiles` model */
3846
public async init(): Promise<ProfileWatcher> {

plugins/plugin-codeflare/src/tray/watchers/profile/run.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,15 @@ export default class ProfileRunWatcher {
4040
private readonly updateFn: UpdateFunction,
4141
private readonly profile: string,
4242
private readonly watcher = chokidar.watch(ProfileRunWatcher.path(profile) + "/*", { depth: 1 })
43-
) {}
43+
) {
44+
// we need to close the chokidar watcher before exit, otherwise
45+
// electron-main dies with SIGABRT
46+
import("electron").then((_) =>
47+
_.app.on("will-quit", async () => {
48+
await this.watcher.close()
49+
})
50+
)
51+
}
4452

4553
private static path(profile: string) {
4654
return Profiles.guidebookJobDataPath({ profile })

0 commit comments

Comments
 (0)