Skip to content

fix: proxy input always fails due to an undici version mismatch - #675

Merged
zimeg merged 8 commits into
slackapi:mainfrom
githubdev58yashi:fix/proxy-fetch-undici-version-mismatch
Nov 20, 2026
Merged

zimeg merged 8 commits into
slackapi:mainfrom
githubdev58yashi:fix/proxy-fetch-undici-version-mismatch

Conversation

@githubdev58yashi

Copy link
Copy Markdown
Contributor

Summary

Setting the proxy input always makes requests fail. It doesn't matter whether the proxy or the destination is actually reachable.

TypeError: fetch failed
Cause: InvalidArgumentError: invalid onRequestStart method

The cause is a version mismatch inside undici. src/proxies.js builds a ProxyAgent dispatcher from the npm undici package (^8.9.0), but drives it with globalThis.fetch. On Node 24, globalThis.fetch is backed by a different, older bundled undici (7.21.0). undici made a breaking change to its request handler interface between v7 and v8 (see the v8.0.0 release notes), so the mismatch throws before any network I/O even starts.

The fix is to use undici's own exported fetch instead of the global one. That keeps the dispatcher and the fetch implementation on the same undici version.

-import { ProxyAgent } from "undici";
+import { ProxyAgent, fetch as undiciFetch } from "undici";
-  return (url, init) => globalThis.fetch(url, { ...init, dispatcher });
+  return (url, init) => undiciFetch(url, { ...init, dispatcher });

This only affects requests made while the proxy input is set. The call path is src/client.js#L26 / src/webhook.js#L22 → proxies.js.

This mismatch was introduced in v4, when both SDKs switched from axios to the Fetch API and this proxy dispatcher started depending on undici (#619). It went unnoticed until a later undici v7 → v8 bump (#653) actually broke it.

Testing

Added a test to test/proxies.spec.js that actually calls the function fetch() returns, instead of only checking its type. That gap is why the bug went unnoticed — the existing tests never called the returned function. No real server is needed: the mismatch happens synchronously, before any network I/O, so pointing the proxy at a closed local port is enough to catch a regression.

Also verified by running the actual packaged action (dist/index.js, runs.using: node24) through act (Docker). Before the fix, the underlying cause is InvalidArgumentError UND_ERR_INVALID_ARG invalid onRequestStart method. After the fix, it's Error ECONNREFUSED — a normal network error, since nothing listens on the test proxy port.

Log excerpt (before / after)

Before:

❗  ::error::SlackError: A request error occurred: fetch failed
error.message: fetch failed
cause: InvalidArgumentError UND_ERR_INVALID_ARG invalid onRequestStart method

After:

❗  ::error::SlackError: A request error occurred: fetch failed
error.message: fetch failed
cause: Error ECONNREFUSED connect ECONNREFUSED 127.0.0.1:1

The action's own warning/error text looks almost the same before and after, since SlackError doesn't propagate .cause. The cause error type is the reliable way to tell them apart, and that's exactly what the new test checks.

Requirements

The ProxyAgent dispatcher is built with the npm "undici" package (v8),
but was driven by globalThis.fetch, which Node bundles from a
different (older) undici version. A breaking change to undici's
request handler interface between v7 and v8 made every proxied
request fail before any network I/O, regardless of whether the proxy
or destination was reachable.

Use undici's own exported fetch instead so the dispatcher and the
fetch implementation always come from the same undici version.
@githubdev58yashi
githubdev58yashi requested a review from a team as a code owner August 21, 2026 15:15
@changeset-bot

changeset-bot Bot commented Aug 21, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 2327260

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@slack/slack-github-action Patch

Not sure what this means? Click here to learn what changesets are.

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

@codecov

codecov Bot commented Aug 21, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.86%. Comparing base (ec0f442) to head (2327260).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #675   +/-   ##
=======================================
  Coverage   99.86%   99.86%           
=======================================
  Files           8        8           
  Lines         732      732           
=======================================
  Hits          731      731           
  Misses          1        1           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@zimeg zimeg added semver:patch javascript Pull requests that update Javascript code labels Nov 19, 2026
@zimeg zimeg added this to the 4.1 milestone Nov 19, 2026
zimeg and others added 2 commits November 19, 2026 23:54
Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>

@zimeg zimeg left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 Small adjustments to words quick-

Comment thread .github/dependabot.yml Resolved
Comment thread test/proxies.spec.js Resolved
zimeg and others added 3 commits November 20, 2026 00:48
# Conflicts:
#	package-lock.json
#	package.json
Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
@zimeg

zimeg commented Nov 20, 2026

Copy link
Copy Markdown
Member

🎉 @githubdev58yashi Thanks so much for tracking this down and for your patience on a review! I pushed a few changes to land this:

  • 📦 undici@7 now matches the undici that the node24 runtime bundles for its global fetch, and that line is supported until 2028-04-30 (long-term support). With matching versions, src/proxies.js keeps the global fetch with a ProxyAgent dispatcher. Using undici's own fetch fixed the dispatcher error, but file uploads build bodies with the global FormData, which undici's own fetch doesn't recognize, so files.uploadV2 sent the text [object FormData] instead of the file.
  • 🧪 A new test sends a FormData upload through a local proxy and checks that it arrives as a multipart body. The proxy test from this PR now uses the node:test mocks from test: replace sinon with node:test mocks #707.
  • 🤖 Dependabot now skips undici@8 updates, with a link to the support table for the reason.
  • 📝 The changeset describes the fix, and the branch is current with main.

🧪 Tests passed on 2327260: unit tests and API and CLI tests.

@zimeg
zimeg merged commit 7eee320 into slackapi:main Nov 20, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working cla:signed javascript Pull requests that update Javascript code semver:patch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants