Skip to content

fix(desktop): use native fetch in the Electron main process - #14746

Merged
dylanjeffers merged 1 commit into
mainfrom
fix/electron-native-fetch
Nov 7, 2026
Merged

dylanjeffers merged 1 commit into
mainfrom
fix/electron-native-fetch

Conversation

@dylanjeffers

Copy link
Copy Markdown
Contributor

Summary

Fixes #14745: the desktop app (reported on the Linux AppImage, 1.5.180) crashes on launch with Cannot find module 'node-fetch'.

packages/web/src/electron.js requires node-fetch, but node-fetch is only a devDependency of @audius/web, so electron-builder leaves it out of app.asar. Electron 33 ships Node 20, which has fetch built in, so this drops the require.

Changes

  • Remove require('node-fetch') and use the global fetch.
  • The web-update download used data.body.pipe(), which only exists on node-fetch responses. It now uses pipeline(Readable.fromWeb(data.body), fs.createWriteStream(...)).
  • If S3 returns a non-2xx, the download logs and skips the update instead of writing the error page to disk as the .tar.gz.

node-fetch stays in devDependencies even though nothing else in web uses it. Removing it changes package-lock.json, which triggers Mobile CI/CD and an automatic OTA on main. That can go in a separate cleanup.

Testing

  • node --check and eslint pass on electron.js.
  • Ran the download logic under the installed Electron 33.0.0 binary in Node mode (Node 20.18.0) against a local server:
    • fetch and Readable.fromWeb are available.
    • A 5 MB file streams to disk byte-for-byte.
    • A 404 reports ok=false.
    • .text() works for the package.json check.
  • Not tested: a packaged AppImage build.

— 🏹 Legolas

🤖 Generated with Claude Code

node-fetch is only a devDependency of @audius/web, so electron-builder
leaves it out of app.asar and the packaged app crashes on launch with
"Cannot find module 'node-fetch'" (#14745). Electron 33 ships Node 20,
which has fetch built in, so drop the require. The web-update download
now converts the web ReadableStream with Readable.fromWeb, since
.body.pipe() only exists on node-fetch responses, and skips the update
instead of writing an error page to disk when S3 returns a non-2xx.

Fixes #14745

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dylanjeffers dylanjeffers added the bug Something isn't working label Nov 6, 2026
@changeset-bot

changeset-bot Bot commented Nov 6, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: bfc06c3

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@dylanjeffers
dylanjeffers merged commit 1440372 into main Nov 7, 2026
18 checks passed
@dylanjeffers
dylanjeffers deleted the fix/electron-native-fetch branch November 7, 2026 01:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working size/S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Linux AppImage 1.5.180 fails to start: Cannot find module 'node-fetch'

1 participant