Repository navigation
fix(desktop): use native fetch in the Electron main process - #14746
Merged
Merged
Conversation
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>
|
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.
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.jsrequiresnode-fetch, butnode-fetchis only a devDependency of@audius/web, so electron-builder leaves it out ofapp.asar. Electron 33 ships Node 20, which hasfetchbuilt in, so this drops the require.Changes
require('node-fetch')and use the globalfetch.data.body.pipe(), which only exists on node-fetch responses. It now usespipeline(Readable.fromWeb(data.body), fs.createWriteStream(...))..tar.gz.node-fetchstays in devDependencies even though nothing else in web uses it. Removing it changespackage-lock.json, which triggers Mobile CI/CD and an automatic OTA onmain. That can go in a separate cleanup.Testing
node --checkand eslint pass onelectron.js.fetchandReadable.fromWebare available.ok=false..text()works for thepackage.jsoncheck.— 🏹 Legolas
🤖 Generated with Claude Code