fix(ci): patch danger to decline gzip, fixing ERR_STREAM_PREMATURE_CLOSE on Node 24 - #22171
Conversation
…OSE on Node 24 Danger's danger:ci check started failing intermittently with FetchError: Premature close (ERR_STREAM_PREMATURE_CLOSE) when fetching PR files, diff and commits from the GitHub API. Root cause: the Node 22.23.0 / 24.17.0 security fix for CVE-2026-48931 (http.Agent response-queue poisoning) attaches a 'data' listener to idle keep-alive sockets. node-fetch@2 misreads this as an unclean connection close on gzip-encoded responses without Content-Length (exactly what api.github.com returns), producing false-positive premature-close errors. The GitHub-hosted runners rolling into the patched Node 24.17.x is why this surfaced now. node-fetch@2 can't be removed downstream (danger imports it directly and it is pervasive transitively), and we don't want to pin an old Node. Instead, bump danger 13.0.4 -> 13.0.8 and backport danger/danger-js#1516 via a yarn patch: set `compress: false` on danger's shared api() wrapper so GitHub returns identity-encoded responses with Content-Length and node-fetch's faulty detector never fires. Negligible bandwidth cost on these small JSON payloads; explicit caller overrides are preserved. Drop the patch and bump once #1516 ships in a danger release.
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
There was a problem hiding this comment.
Pull request overview
This PR stabilizes the twenty-utils:danger:ci GitHub Actions check on Node 24 by upgrading danger and applying a Yarn patch that disables gzip compression in Danger’s GitHub API fetch wrapper, avoiding node-fetch@2’s ERR_STREAM_PREMATURE_CLOSE failures on gzipped/chunked responses.
Changes:
- Upgrade
dangerfrom13.0.4to13.0.8withinpackages/twenty-utils. - Route
dangerthrough a Yarnpatch:dependency to backport thecompress: falsebehavior indistribution/api/fetch.js. - Update
yarn.lockto reflect the newdangerversion and patched resolution.
Reviewed changes
Copilot reviewed 2 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| yarn.lock | Updates the lockfile to include danger@13.0.8 and the danger@patch: resolution used by twenty-utils. |
| packages/twenty-utils/package.json | Switches the danger devDependency to the patched 13.0.8 spec. |
| .yarn/patches/danger-npm-13.0.8-48aba2788c.patch | Backports the init.compress = false default (guarded by === undefined) to decline gzip responses. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
🔍 Visual Regression Review —
|
🔍 Visual Regression Review —
|
| Story | Verdict | Confidence | Explained by | |
|---|---|---|---|---|
| 🟡 | modules-settings-playground-graphqlplayground--default |
uncertain | 82% | No UI code changed — PR only modifies .yarn/patches/danger-npm-13.0.8-48aba2788c… |
| 🟡 | modules-settings-accounts-blocklist-settingsaccountsblocklistsection--default |
uncertain | 82% | No UI code changed — PR only modifies .yarn/patches/danger-npm-13.0.8-48aba2788c… |
| 🟡 | modules-objectrecord-objectoptionsdropdown-objectoptionsdropdowncontent--record-… |
uncertain | 75% | No UI code changed — PR only modifies .yarn/patches/danger-npm-13.0.8-48aba2788c… |
| 🟡 | ui-data-field-input-numberfieldinput--default |
uncertain | 85% | No UI code changed — PR only modifies .yarn/patches/danger-npm-13.0.8-48aba2788c… |
Changed stories
| Story | Diff % |
|---|---|
| modules-settings-playground-graphqlplayground--default | 3% |
| modules-settings-accounts-blocklist-settingsaccountsblocklistsection--default | 1% |
| modules-objectrecord-objectoptionsdropdown-objectoptionsdropdowncontent--record-group-fields | 1% |
| ui-data-field-input-numberfieldinput--default | 0% |
| modules-ai-terminaloutput--stdout-only | 0% |
View run details · advisory mode
Problem
The
danger-jscheck (twenty-utils:danger:ci) started failing intermittently with:It fails before the Dangerfile even runs, while fetching PR files / diff / commits. The existing retry wrapper (#22151) reduced it but can't absorb longer GitHub-API windows, so checks still go red.
Root cause
Not "node-fetch is old" generically — a specific recent regression:
'data'listener to idle keep-alive sockets.node-fetch@2misreads that listener as an unclean connection close — but only on gzip-encoded responses withoutContent-Length, which is exactly whatapi.github.comreturns.See danger/danger-js#1515, nodejs/node#63989.
Why this approach
node-fetch@2can't be removed downstream — Danger imports it directly, and it's pervasive transitively (gaxios/googleapis). Dropping it is an upstream migration.So: bump
danger13.0.4 → 13.0.8 and backport danger/danger-js#1516 via a yarn patch — setcompress: falseon Danger's sharedapi()wrapper. GitHub then returns identity-encoded responses withContent-Length, and node-fetch's faulty premature-close detector never fires. Negligible bandwidth cost on these small JSON payloads; explicit caller overrides are preserved via an=== undefinedguard.Changes
packages/twenty-utils/package.json—danger→ patched 13.0.8yarn.lock— registers thedanger@patch:resolution.yarn/patches/danger-npm-13.0.8-48aba2788c.patch— thecompress: falsefixVerification
compressfix is present in the linkeddistribution/api/fetch.js.getPullRequestInfo/getPullRequestCommits/getPullRequestDiff) all route throughthis.api→ the patched wrapper.Lifecycle
Temporary backport. When #1516 ships in a Danger release, drop the patch and bump to that version (flagged in a comment inside the patch). The existing CI retry wrapper stays as defense-in-depth.