openai / openai/codex

[macOS] Downloading a generated image from a remote task throws a getOwnerBrowserWindow error

Open
#46,638 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

app bug imagen
Dominant language
Rust
Stars
125k
Forks
19.4k
PR merge metrics
PR metrics pending

Description

What version of the Codex App are you using?

26.915.31945 (build 9922)

What subscription do you have?

ChatGPT Pro x20

What platform is your computer?

macOS 26.6.2 (25G83), Apple Silicon.

Output of uname -mprs:

Darwin 25.6.0 arm64 arm

What issue are you seeing?

When I try to download an image generated in a Codex task using a remote repository, the desktop app shows “A JavaScript error occurred in the main process.”

The full exception is:

Uncaught Exception:
TypeError: Cannot read properties of null (reading 'getOwnerBrowserWindow')
    at n.fromWebContents (node:electron/js2c/browser_init:2:20067)
    at Session.l (/Applications/ChatGPT.app/Contents/Resources/app.asar/.vite/build/main-DUHZj4_w.js:1603:214221)
    at Session.emit (node:events:521:24)

What steps can reproduce the bug?

  1. Open a task for a remote repository in the desktop app.
  2. Generate an image in that task.
  3. Try to download the image.
  4. The error dialog above appears.

What is the expected behavior?

The image should download normally. If the download fails, the app should show an error message instead of an uncaught JavaScript exception.

Additional information

What the stack trace points to

In the installed app bundle, main-DUHZj4_w.js:1603:214221 points to this call in the bundled electron-dl listener:

const window_ = BrowserWindow.fromWebContents(webContents);

The listener passes webContents to fromWebContents() without checking for null. The existing if (!window_) check runs after the call, so it cannot catch this error.

The same code is present in electron-dl at commit 141a97b. Electron's implementation calls webContents.getOwnerBrowserWindow() directly, which throws the reported TypeError when webContents is null.

The app depends on electron-context-menu, which uses electron-dl to save images.

Tests

  • Passing null webContents to the listener extracted from the app reproduced the exact TypeError.
  • A standalone Electron 30.5.1 app reproduced the same error with the unmodified upstream library, using session.downloadURL() and a local HTTP server. The event's webContents is null in this case.
  • With the prepared library fix, all three native Electron tests pass: session downloads, a detached WebContentsView, and ordinary window downloads. The tests also check cancellation, listener cleanup, saved file contents, and progress counters across consecutive downloads.

The extracted-bundle test used mocked Electron APIs. The standalone tests use actual Electron. They confirm the library failure, but do not explain why the original app download event had null webContents.

Upstream report and patch

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the electron-dl listener identified in main-DUHZj4_w.js and the dependency path through electron-context-menu. Reproduce the remote-task image download, then run the native Electron cases described in the issue, including session downloads and ordinary window downloads. Done means the image downloads successfully or reports an error without an uncaught getOwnerBrowserWindow exception.

Written by the indexing model from the issue text.

Assessment

Tech stack
electron, javascript, macos
Domain
desktop
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.