Skip to content

enterprise-util: Do not use app.quit() in case of renderer process. #1430

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
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
8 changes: 7 additions & 1 deletion app/common/enterprise-util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import process from "node:process";
import {z} from "zod";
import {dialog} from "zulip:remote";

import {ipcRenderer} from "../renderer/js/typed-ipc-renderer.js";
Copy link
Member

Choose a reason for hiding this comment

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

This is worse. We should not import either main-only APIs or renderer-only APIs from common. Our linter configuration is supposed to enforce this, but that enforcement appears to be broken somehow.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not sure why this is worse. Can you explain why? Thanks :)

Copy link
Member

Choose a reason for hiding this comment

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

#1425 incorrectly imports a main-only API into common. This incorrectly imports both a main-only API and also a renderer-only API into common. We should import neither here, not both.

I understand that you think you’re avoiding issues by checking process.type, but (1) a linter cannot automatically verify that you did that check correctly, (2) it’s too easy to forget to check manually, and (3) the import itself has side effects that can’t be conditionalized.


import {enterpriseConfigSchemata} from "./config-schemata.js";
import Logger from "./logger-util.js";

Expand Down Expand Up @@ -52,7 +54,11 @@ function reloadDatabase(): void {
// 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();
if (process.type === "renderer") {
ipcRenderer.send("quit-app");
} else {
app.quit();
}
}
} else {
configFile = false;
Expand Down