Skip to content

fix(settings): handle empty or corrupted windows.json without crashing - #536

Open
Wasdalt wants to merge 1 commit into
forge-ext:mainfrom
Wasdalt:fix-empty-config-handling
Open

Wasdalt wants to merge 1 commit into
forge-ext:mainfrom
Wasdalt:fix-empty-config-handling

Conversation

@Wasdalt

@Wasdalt Wasdalt commented Sep 11, 2026

Copy link
Copy Markdown

Problem

If ~/.config/forge/config/windows.json exists but is empty (0 bytes) or contains invalid JSON, JSON.parse throws a SyntaxError: unexpected end of data at line 1 column 1, causing the GNOME extension to fail initialization and enter ERROR state.

In addition, loadFile did not close the file stream when creating the default config, which could lead to empty files being created.

Solution

  1. In get windowProps(), wrap JSON.parse in a try...catch block and verify that windowConfigContents is a non-empty string. Fall back to loadDefaultWindowConfigContents() if parsing fails.
  2. In loadFile(), ensure the created stream is closed via close() and return the newly created file descriptor instead of null

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant