Skip to content

Commit 2341add

Browse files
dbfxclaude
andcommitted
fix: about view crash due to process.versions in sandboxed renderer
process.versions is not available in Electron's renderer with context isolation enabled. Expose versions through the preload bridge instead. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 3e979de commit 2341add

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

src/main/preload.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,15 @@ contextBridge.exposeInMainWorld('mtrApi', {
3535
return () => { ipcRenderer.removeListener('loss:data', listener as (...args: unknown[]) => void); };
3636
},
3737

38-
// Auto-updater
38+
// App info
3939
getVersion: () => ipcRenderer.invoke('app:version'),
40+
getProcessVersions: () => ({
41+
electron: process.versions.electron,
42+
chrome: process.versions.chrome,
43+
node: process.versions.node,
44+
}),
45+
46+
// Auto-updater
4047
checkForUpdates: () => ipcRenderer.invoke('updater:check'),
4148
downloadUpdate: () => ipcRenderer.invoke('updater:download'),
4249
installUpdate: () => ipcRenderer.invoke('updater:install'),

src/renderer/components/AboutView.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ export default function AboutView() {
88
const [updateStatus, setUpdateStatus] = useState<UpdateStatus>('idle');
99
const [downloadPercent, setDownloadPercent] = useState(0);
1010

11+
const processVersions = window.mtrApi.getProcessVersions();
12+
1113
useEffect(() => {
1214
window.mtrApi.getVersion().then(setVersion);
1315

@@ -131,9 +133,9 @@ export default function AboutView() {
131133
<div className="flex flex-col gap-2">
132134
<InfoRow label="Author" value="Dave" />
133135
<InfoRow label="License" value="MIT" />
134-
<InfoRow label="Electron" value={process.versions.electron || 'N/A'} />
135-
<InfoRow label="Chrome" value={process.versions.chrome || 'N/A'} />
136-
<InfoRow label="Node" value={process.versions.node || 'N/A'} />
136+
<InfoRow label="Electron" value={processVersions.electron} />
137+
<InfoRow label="Chrome" value={processVersions.chrome} />
138+
<InfoRow label="Node" value={processVersions.node} />
137139
</div>
138140
</div>
139141
</motion.div>

src/renderer/types/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export interface MtrApi {
1111
stopLossMonitor: () => Promise<void>;
1212
onLossData: (callback: (state: LossMonitorState) => void) => () => void;
1313
getVersion: () => Promise<string>;
14+
getProcessVersions: () => { electron: string; chrome: string; node: string };
1415
checkForUpdates: () => Promise<void>;
1516
downloadUpdate: () => Promise<void>;
1617
installUpdate: () => Promise<void>;

0 commit comments

Comments
 (0)