Last updated: · Applies to: Codex in VS Code; webview ServiceWorker registration failures

Codex: Could not register service worker in VS Code

Could not register service worker: InvalidStateError: Failed to register a ServiceWorker: The document is in an invalid state. identifies a VS Code webview registration failure. Start with a complete editor exit and an isolated test. The same error appears with other extensions in the VS Code repository; it does not establish a Codex account problem.

What the reports confirm

A Fedora report, #58111, lists VS Code 1.144.0: stable 26.1021.22027 and pre-release 26.51021.22027 failed, while older stable 26.1007.21434 worked for that reporter. This is a reported comparison, not proof every registration failure shares one regression.

Recover without deleting editor state

  1. Save work and fully close your editor

    Close all your VS Code windows. Check for remaining editor processes belonging to your session; confirm their ownership before ending any residual process tree. Then reopen VS Code and retry. A VS Code contributor suggested restarting and the reporter confirmed recovery. Reloading one webview may leave the affected process alive.

  2. Compare a disposable installation environment

    The official CLI documents separate user-data and extension directories. For a standard, non-portable VS Code installation, run this in Windows Command Prompt (cmd.exe), not PowerShell:

    code --user-data-dir "%TEMP%\codex-webview-test-data" --extensions-dir "%TEMP%\codex-webview-test-extensions"

    Use new, unused directories; substitute equivalent temporary paths on Linux or macOS. In Portable Mode, the data folder overrides --user-data-dir and --extensions-dir, so this command does not provide that isolation. With a standard, non-portable installation, install Codex only in that isolated environment and test it there; using these separate directories leaves your existing profile unchanged. A successful isolated test narrows the problem to an environment difference; it does not identify which cache or extension caused it.

  3. On Windows only, consider a reversible cache rename

    In a historical Windows 10 / Server 2016 thread, fr3nch13’s August 28 comment describes VS Code 1.135.0 and Codex 26.825.32147. Reload Webviews failed; residual Code.exe network/ServiceWorker processes remained. Fully stopping the editor, then renaming %APPDATA%\Code\Service Worker to an unused backup name restored local and Dev Container use without modifying state.vscdb.

    Only try this after full editor exit. Keep the backup, restart and test. If ineffective, stop the editor again, move any newly created Service Worker directory aside and restore the backup’s original name. This is one user’s workaround, not a universal cure. Do not blanket-delete .codex, globalStorage, workspaceStorage or state.vscdb.

  4. Consider a matching version regression

    If versions and symptoms match #58111, the existing rollback guide explains selecting stable 26.1007.21434. The 26.5xxxx builds cited here are pre-release. A secondary renderer_ready_timeout can accompany this failure; retain the explicit ServiceWorker error as the more specific diagnostic clue.

  5. Verify the result and report safely

    Confirm the sidebar opens and a small request completes. If not, provide OS, VS Code and Codex versions, local/remote context, exact registration error and isolated-test results. Sanitize logs before posting; remove credentials, account identifiers and private paths.

FAQ

Does this error mean my Codex account is broken?

No. It identifies a webview ServiceWorker registration failure. Reports with other extensions show that the error alone cannot establish a Codex account cause.

Should I delete state.vscdb or all Codex data?

No. The cited Windows workaround preserved state.vscdb and renamed only the Service Worker directory after full editor exit. Keep a backup and restore it if the test is ineffective.

Will stable 26.1007.21434 fix every ServiceWorker error?

No. It worked for the Fedora reporter in issue #58111. Treat it as a reported workaround for matching symptoms and versions, then verify the sidebar and a small request.

Sources

This is an independent, unofficial help site. It is not affiliated with or endorsed by OpenAI. Check the linked documentation and reports for your environment.