fix: remove invalid state: 'normal' from chrome.windows.create()#559
Merged
jackwener merged 2 commits intojackwener:mainfrom Mar 28, 2026
Merged
Conversation
Chrome 146+ rejects 'normal' as an invalid value for the `state` parameter
in chrome.windows.create(). This causes the error:
Error: Invalid value for state
Root cause analysis:
- The Chrome Extensions API documentation states that `state` parameter
only accepts 'minimized', 'maximized', and 'fullscreen' as input values
- While WindowState enum includes 'normal', it's meant for reading window
state, not for setting it during creation
- Chrome 146 enforces stricter validation on the `state` parameter
- When `state` is omitted, the window defaults to 'normal' state anyway
Fix: Remove the `state: 'normal'` parameter entirely. The window will
default to normal state without explicitly setting it.
Tested: `opencli doctor` and `opencli bilibili hot` now work correctly
on Chrome 146.0.7680.165.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When running
opencli bilibili hot(or any browser-based command) on Chrome 146+, the command fails with:Running
opencli doctorshows:Root Cause Analysis
1. Chrome API Documentation
According to the Chrome Extensions API documentation, the
stateparameter forchrome.windows.create()is described as:Key finding: The
stateparameter only accepts'minimized','maximized', and'fullscreen'as input values. The value'normal'is NOT a valid input forchrome.windows.create().2. WindowState Enum vs. state Parameter Input
While the
WindowStateenum definition includes"normal":This enum is used for reading window state (return value), not for setting window state during creation.
3. Chrome 146 Behavior Change
Chrome 146 (tested on 146.0.7680.165) now enforces stricter validation on the
stateparameter. Previous Chrome versions may have silently ignored invalidstatevalues, but Chrome 146 throws an error.4. The Bug
In
extension/src/background.ts:163-170:Solution
Remove the
state: 'normal'parameter entirely. Whenstateis not specified, the window defaults to 'normal' state anyway.Testing
Environment:
After applying the fix:
opencli doctorpasses all checksopencli bilibili hotreturns results correctlyReferences