Repository navigation
Require Node 26 and update superagent to fix crash on redirecting images - #5
Open
jeremywarrick wants to merge 2 commits into
Open
jeremywarrick wants to merge 2 commits into
jeremywarrick wants to merge 2 commits into
Conversation
epub-gen downloads article images with superagent 3.8.3, whose redirect handler reads the private `ClientRequest#_headers` property. Node.js removed that property (DEP0066 end-of-life; it is `undefined` on Node 24, 25 and 26), so `utils.cleanHeader(undefined)` throws "TypeError: Cannot convert undefined or null to object" from inside a socket callback. That exception is uncaught and terminates the whole server process whenever an article contains an image URL that returns a 301/302/303 redirect. Patch superagent via `yarn patch` to read headers through the public `getHeaders()` API (falling back to `_headers` on old runtimes), and copy `.yarn/patches/` into the Docker build context so the patched resolution installs inside the image. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EpKf8Li5Lv7SsxKXrMvGZP
Owner
|
Thanks for submitting. Rather than patching the dependency to shim in support for both new/old Nodes, I think I'd rather just bump the project's Node requirement up to >=24 (or probably just 26, the current LTS). I will try to get to this when I can, but if you're interested in taking that on I'll be happy to merge it in as well! |
Author
|
that sounds even better, let me (have Fable) give it a go! |
Per review on BHSPitMonkey#5: rather than shimming superagent 3.8.3 to work on both old and new Node versions, raise the project's Node requirement to 26 (current LTS) and resolve epub-gen's superagent dependency to the maintained 10.x line, which reads request headers through the public getHeaders() API. - package.json: engines.node ">= 26.0.0"; @types/node ^26; resolution superagent@npm:^3.8.3 -> npm:^10.4.2 (replaces the patch: resolution) - Remove .yarn/patches/superagent-npm-3.8.3-*.patch - Dockerfile: node:26 base image; drop the .yarn/patches COPY - .nvmrc: v26 - README: note the Node 26 requirement - yarn.lock, .pnp.cjs: regenerated Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EpKf8M1442k2PDhNiHy9ij
Author
|
Thanks for the suggestion! Updated in 8d77770:
Tested on a Pi 5 with Node 26: the article that used to crash now converts, all 12 current HN front-page articles converted (53 image downloads, no errors or restarts), and a Docker-style clean install works. Details are in the updated description. |
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
Articles with a redirecting image (e.g. GitHub README badges) crash the server on Node 24+. This PR makes Node 26 the minimum and updates superagent so redirects work on it.
Why updating Node alone wasn't enough
epub-gendownloads images withsuperagent@3.8.3, whose redirect handler reads Node's privateClientRequest#_headers(DEP0066). That property only exists up to Node 22; on 24+ it'sundefined, so every redirect throws an uncaughtTypeErrorand the process exits. Raising the minimum to 26 by itself would make the crash happen everywhere, so superagent had to be updated too.Changes
engines.node >= 26.0.0,@types/node ^26,.nvmrcv26, DockerfileFROM node:26, README note.resolutionsentry pointsepub-gen'ssuperagent@^3.8.3at^10.4.2. 10.x reads headers through the publicgetHeaders()API and still supports theget().set().pipe()calls andend/errorevents thatepub-genuses. No patch files and nosrc/changes.yarn.lockand.pnp.cjsregenerated.Testing (Raspberry Pi 5, Node 26.7.0)
package.json,yarn.lockanddist/): installs and serves correctly.docker builditself wasn't run because Docker isn't available on this machine.🤖 Generated with Claude Code
https://claude.ai/code/session_01EpKf8M1442k2PDhNiHy9ij