Vikas Bansal
Vikas Bansal

Reputation: 11730

ElectronJs: app.quit is crashing the application

Task Terminate the application when all the windows are closed or the Main Window is closed.

Problem application crashing when the app.quit() is called.

Code

app.on('window-all-closed', function () {
    // if (process.platform !== 'darwin') {
    //     app.quit();
    // }

    app.quit();
});



mainWindow.on('closed', function () {
    mainWindow = null;
    app.quit();

});

Log

[901:0531/114426:FATAL:resource_dispatcher_host_impl.cc(658)] Check failed: ContainsKey(active_resource_contexts_, context). 
0   Electron Framework                  0x000000010bfa3903 _ZN4base8internal30DstRangeRelationToSrcRangeImplIilLNS0_21IntegerRepresentationE1ELS2_1ELNS0_26NumericRangeRepresentationE0EE5CheckEl + 389891
1   Electron Framework                  0x000000010bfb9ec9 _ZN4base8internal30DstRangeRelationToSrcRangeImplIilLNS0_21IntegerRepresentationE1ELS2_1ELNS0_26NumericRangeRepresentationE0EE5CheckEl + 481481
2   Electron Framework                  0x000000010c83b765 _ZN4base8internal30DstRangeRelationToSrcRangeImplIilLNS0_21IntegerRepresentationE1ELS2_1ELNS0_26NumericRangeRepresentationE0EE5CheckEl + 9400677
3   Electron Framework                  0x000000010c8ff0cc _ZN4base8internal30DstRangeRelationToSrcRangeImplIilLNS0_21IntegerRepresentationE1ELS2_1ELNS0_26NumericRangeRepresentationE0EE5CheckEl + 10201804
4   Electron Framework                  0x000000010bf15009 _ZN9brightray14BrowserContext15ResourceContextD2Ev + 9
5   Electron Framework                  0x000000010bf14f79 _ZN9brightray14BrowserContext15ResourceContextD1Ev + 9
6   Electron Framework                  0x000000010bf14f8e _ZN9brightray14BrowserContext15ResourceContextD1Ev + 30
7   Electron Framework                  0x000000010bf158cf _ZN4base12DeleteHelperIN9brightray14BrowserContext15ResourceContextEE8DoDeleteEPKv + 15
8   Electron Framework                  0x000000010bfa3e0b _ZN4base8internal30DstRangeRelationToSrcRangeImplIilLNS0_21IntegerRepresentationE1ELS2_1ELNS0_26NumericRangeRepresentationE0EE5CheckEl + 391179
9   Electron Framework                  0x000000010bfc2973 _ZN4base8internal30DstRangeRelationToSrcRangeImplIilLNS0_21IntegerRepresentationE1ELS2_1ELNS0_26NumericRangeRepresentationE0EE5CheckEl + 516979
10  Electron Framework                  0x000000010bfc2c4c _ZN4base8internal30DstRangeRelationToSrcRangeImplIilLNS0_21IntegerRepresentationE1ELS2_1ELNS0_26NumericRangeRepresentationE0EE5CheckEl + 517708
11  Electron Framework                  0x000000010bfc2e3b _ZN4base8internal30DstRangeRelationToSrcRangeImplIilLNS0_21IntegerRepresentationE1ELS2_1ELNS0_26NumericRangeRepresentationE0EE5CheckEl + 518203
12  Electron Framework                  0x000000010bf98a31 _ZN4base8internal30DstRangeRelationToSrcRangeImplIilLNS0_21IntegerRepresentationE1ELS2_1ELNS0_26NumericRangeRepresentationE0EE5CheckEl + 345137
13  Electron Framework                  0x000000010bfd57e3 _ZN4base8internal30DstRangeRelationToSrcRangeImplIilLNS0_21IntegerRepresentationE1ELS2_1ELNS0_26NumericRangeRepresentationE0EE5CheckEl + 594403
14  Electron Framework                  0x000000010bfc216d _ZN4base8internal30DstRangeRelationToSrcRangeImplIilLNS0_21IntegerRepresentationE1ELS2_1ELNS0_26NumericRangeRepresentationE0EE5CheckEl + 514925
15  Electron Framework                  0x000000010c6e7b38 _ZN4base8internal30DstRangeRelationToSrcRangeImplIilLNS0_21IntegerRepresentationE1ELS2_1ELNS0_26NumericRangeRepresentationE0EE5CheckEl + 8009016
16  Electron Framework                  0x000000010c6e7d0e _ZN4base8internal30DstRangeRelationToSrcRangeImplIilLNS0_21IntegerRepresentationE1ELS2_1ELNS0_26NumericRangeRepresentationE0EE5CheckEl + 8009486
17  Electron Framework                  0x000000010bff4758 _ZN4base8internal30DstRangeRelationToSrcRangeImplIilLNS0_21IntegerRepresentationE1ELS2_1ELNS0_26NumericRangeRepresentationE0EE5CheckEl + 721240
18  Electron Framework                  0x000000010bff0937 _ZN4base8internal30DstRangeRelationToSrcRangeImplIilLNS0_21IntegerRepresentationE1ELS2_1ELNS0_26NumericRangeRepresentationE0EE5CheckEl + 705335
19  libsystem_pthread.dylib             0x00007fff8780405a _pthread_body + 131
20  libsystem_pthread.dylib             0x00007fff87803fd7 _pthread_body + 0
21  libsystem_pthread.dylib             0x00007fff878013ed thread_start + 13

enter image description here

Upvotes: 2

Views: 1620

Answers (1)

ccnokes
ccnokes

Reputation: 7105

You're calling app.quit() twice which is causing the crash. Only call it once in either the all-windows-closed event handler or closed event handler on the mainWindow.

Upvotes: 2

Related Questions