fix(deps): pin undici@8 so pkc-js body-timeout polyfill covers @libp2p/http (#84)#85
Conversation
…p/http Top-level undici was hoisted to 7.x (to satisfy cheerio/open-graph-scraper), but undici changed its global-dispatcher symbol between v7 (undici.globalDispatcher.1) and v8 (.2). pkc-js's setGlobalDispatcher(bodyTimeout: MAX) polyfill writes the slot of whichever undici is hoisted to top-level, while the helia/@libp2p/http path (undici 8.x) reads the .2 slot. With undici 7.x on top, pkc writes .1, @libp2p/http reads an unset .2, and idle pubsub long-poll streams hit undici's default 5-minute bodyTimeout -> UND_ERR_BODY_TIMEOUT (reproducible in Docker, not on host installs where undici 8.x hoists to top). Pin a direct undici@8.4.1 so 8.x wins the top-level hoist (cheerio/open-graph-scraper keep their own nested 7.x); pkc's polyfill then writes .2 and @libp2p/http inherits bodyTimeout: MAX. Adds a regression test asserting top-level undici is major >= 8 and that @libp2p/http resolves to the same major. Refs #84
|
Caution Review failedPull request was closed or merged during review No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThis PR hoists ChangesUndici v8 hoisting for global-dispatcher symbol alignment
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
test/cli/undici-dispatcher-hoisting.test.tsOops! Something went wrong! :( ESLint: 8.27.0 Error: ESLint configuration in --config » eslint-config-oclif is invalid:
Referenced from: /.eslintrc Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Problem
The daemon logs recurring pubsub errors in Docker (not on a host
npm install):Root cause
undici changed its global-dispatcher symbol between v7 and v8:
Symbol.for('undici.globalDispatcher.1')Symbol.for('undici.globalDispatcher.2')(.1legacy only)pkc-js disables undici's default 5-minute
bodyTimeoutfor idle pubsub long-polls viasetGlobalDispatcher(new Agent({ bodyTimeout: MAX })), importing the top-level undici —so it writes the slot of whatever version is hoisted to top.
cheerio/open-graph-scraper(undici@^7) won the top-level hoist → undici7.25.0 on top → pkc writes
.1. The helia/@libp2p/httppath uses undici 8.x andreads
.2(never set) → default 300s body timeout → idle pubsub streams aborted at 5 min..2→ no timeout. Hence"Docker only".
(The kubo-rpc-client pubsub long-poll itself uses native global
fetch, reads.1, and iscovered by the polyfill — the timing-out request is the undici-8.x /
@libp2p/httppath.)Fix
Pin a direct
undici@8.4.1so 8.x wins the top-level hoist (mirroring the working hostlayout). Result:
undici→ 8.4.1@libp2p/http→ deduped to top-level 8.4.1 (no nested copy)cheerio/open-graph-scraper→ keep their own nested 7.xpkc-js's polyfill now writes the
.2slot the@libp2p/httppath reads → idle pubsubstreams inherit
bodyTimeout: MAX.Verification
setGlobalDispatcherdid not govern an undici-8.x request; post-fix it does.
test/cli/undici-dispatcher-hoisting.test.ts(red on the 7.25.0/8.2.0split, green now).
npm run build,npm run build:test, and fullnpm run test:clipass (29 files, 211passed, 1 skipped).
Closes #84
Summary by CodeRabbit
Release Notes
Dependencies