mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-10 01:33:54 +01:00
MISC: Fix ghost processes when Electron code crashes too early (#1238)
This commit is contained in:
parent
d4bdb8de2b
commit
5696db2788
@ -1,7 +1,24 @@
|
||||
/* eslint-disable no-process-exit */
|
||||
/* eslint-disable @typescript-eslint/no-var-requires */
|
||||
const { app, dialog, BrowserWindow, ipcMain, protocol } = require("electron");
|
||||
|
||||
const log = require("electron-log");
|
||||
log.catchErrors();
|
||||
|
||||
// This handler must be set ASAP to prevent ghost processes.
|
||||
process.on("uncaughtException", function () {
|
||||
// The exception will be logged by electron-log.
|
||||
app.quit();
|
||||
process.exit(1);
|
||||
});
|
||||
|
||||
// This handler must be set ASAP to prevent ghost processes.
|
||||
app.on("window-all-closed", () => {
|
||||
log.info("Quitting the app...");
|
||||
app.quit();
|
||||
process.exit(0);
|
||||
});
|
||||
|
||||
const greenworks = require("./greenworks");
|
||||
const api = require("./api-server");
|
||||
const gameWindow = require("./gameWindow");
|
||||
@ -17,15 +34,8 @@ const { fileURLToPath } = require("url");
|
||||
log.transports.file.level = store.get("file-log-level", "info");
|
||||
log.transports.console.level = store.get("console-log-level", "debug");
|
||||
|
||||
log.catchErrors();
|
||||
log.info(`Started app: ${JSON.stringify(process.argv)}`);
|
||||
|
||||
process.on("uncaughtException", function () {
|
||||
// The exception will already have been logged by electron-log
|
||||
app.quit();
|
||||
process.exit(1);
|
||||
});
|
||||
|
||||
// We want to fail gracefully if we cannot connect to Steam
|
||||
try {
|
||||
if (greenworks && greenworks.init()) {
|
||||
@ -42,13 +52,6 @@ try {
|
||||
|
||||
let isRestoreDisabled = false;
|
||||
|
||||
// This was moved so that startup errors do not lead to ghost processes
|
||||
app.on("window-all-closed", () => {
|
||||
log.info("Quitting the app...");
|
||||
app.quit();
|
||||
process.exit(0);
|
||||
});
|
||||
|
||||
function setStopProcessHandler(app, window) {
|
||||
const closingWindowHandler = async (e) => {
|
||||
// We need to prevent the default closing event to add custom logic
|
||||
|
Loading…
Reference in New Issue
Block a user