Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions app/common/enterprise-util.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import {app} from "electron/main";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not work. We’re in app/common here, which is used from both the main process and the renderer process. We’re not allowed to use main process APIs. In practice, we get app === undefined in the renderer process.

Copy link
Member Author

@shubham-padia shubham-padia Jun 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would #1430 be the right approach for rectifying this?

import fs from "node:fs";
import path from "node:path";
import process from "node:process";

import {z} from "zod";
import {dialog} from "zulip:remote";

import {enterpriseConfigSchemata} from "./config-schemata.js";
import Logger from "./logger-util.js";
Expand Down Expand Up @@ -40,8 +42,17 @@ function reloadDatabase(): void {
.partial()
.parse(data);
} catch (error: unknown) {
dialog.showErrorBox(
"Error loading global_config",
"We encountered an error while reading global_config.json, please make sure the file contains valid JSON.",
);
logger.log("Error while JSON parsing global_config.json: ");
logger.log(error);
// This function is called multiple times throughout the
// codebase, making the above dialog.showErrorBox appear
// multiple times and then leading to a non-working app.
// It might be better to quit the app instead.
app.quit();
}
} else {
configFile = false;
Expand Down