Skip to content

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

Open
githubdev58yashi wants to merge 1 commit into
slackapi:mainfrom
githubdev58yashi:fix/proxy-fetch-undici-version-mismatch
Open

fix: proxy input always fails due to an undici version mismatch#675
githubdev58yashi wants to merge 1 commit into
slackapi:mainfrom
githubdev58yashi:fix/proxy-fetch-undici-version-mismatch

Conversation

@githubdev58yashi

Copy link
Copy Markdown

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#L22proxies.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: 83c2ce0

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 (faf8f8f) to head (83c2ce0).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #675   +/-   ##
=======================================
  Coverage   99.86%   99.86%           
=======================================
  Files           8        8           
  Lines         732      735    +3     
=======================================
+ Hits          731      734    +3     
  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.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants