Skip to content

Slack download-file fails silently on Node.js v25 — globalThis.fetch does not support dispatcher option #63393

Closed

Description

@danielhernandez94

Bug

message(action="download-file") for Slack files always returns "File could not be downloaded (not found, too large, or inaccessible)." even when the file exists and the bot token has files:read scope.

Root Cause

createSlackMediaFetch in extensions/slack/src/actions.ts calls globalThis.fetch() and passes through the dispatcher option from the SSRF guard's fetchWithSsrFGuard. In Node.js v25, globalThis.fetch does not support the dispatcher option (only undici.fetch does), causing a TypeError: fetch failed.

The error is silently swallowed by the catch {} in resolveSlackMedia, making the download return null with no logging.

Reproduction

  1. Have a Slack file attachment in any channel
  2. Call message(action="download-file", channel="slack", fileId="F...")
  3. Always returns error, even though files.info API and direct curl with the bot token both work fine
// This fails in Node.js v25:
globalThis.fetch(url, { dispatcher: new undici.Agent(), redirect: 'manual' })
// TypeError: fetch failed

// This works:
undici.fetch(url, { dispatcher: new undici.Agent(), redirect: 'manual' })

Fix

Strip dispatcher from the options before passing to globalThis.fetch in createSlackMediaFetch:

- const { headers: initHeaders, redirect: _redirect, ...rest } = init ?? {};
+ const { headers: initHeaders, redirect: _redirect, dispatcher: _dispatcher, ...rest } = init ?? {};

The SSRF DNS validation still runs upstream in fetchWithSsrFGuard — the dispatcher was only needed for DNS pinning which already completed before the custom fetch is called.

Environment

  • OpenClaw: 2026.4.5
  • Node.js: v25.6.1
  • Platform: macOS arm64

Additional Note

The catch {} in resolveSlackMedia should ideally log the error rather than silently swallowing it, to make debugging easier.

Activity

  1. steipete commented on Apr 25, 2026

    @steipete
    Contributor

    Closing this as implemented after Codex review.

    Current main and released tag v2026.4.23 already route dispatcher-backed Slack media downloads through the runtime Undici fetch path instead of ambient globalThis.fetch, which covers the Node.js v25 failure described in #63393.

    What I checked:

    • Slack media download path avoids ambient fetch when a dispatcher is present: createSlackMediaFetch() checks for dispatcher in the guarded request init and switches to fetchWithRuntimeDispatcher instead of globalThis.fetch, then performs the Slack file request with redirect: "manual". (extensions/slack/src/monitor/media.ts:88, 86f8c826e20a)
    • Shared guarded fetch already falls back to runtime Undici for dispatcher-backed requests: fetchWithSsrFGuard() computes shouldUseRuntimeFetch when a dispatcher is attached and the caller is not using an explicit mocked/stub fetch, then calls fetchWithRuntimeDispatcher(...) rather than the ambient global fetch. (src/infra/net/fetch-guard.ts:393, 86f8c826e20a)
    • Regression test covers the exact Slack dispatcher scenario: media.test.ts asserts that dispatcher-backed Slack media requests do not hit globalThis.fetch, do call fetchWithRuntimeDispatcher, and still carry both redirect: "manual" and the Slack Authorization header. (extensions/slack/src/monitor/media.test.ts:601, 86f8c826e20a)
    • The fix is already shipped in the latest release: The same createSlackMediaFetch() runtime-dispatcher logic is present in release tag v2026.4.23, so this is not only fixed on unreleased main but also in the latest published release. (extensions/slack/src/monitor/media.ts:90, a9797214338b)
    • Related discussion already pointed at the same root cause: The issue timeline cross-references PR fix(slack): strip dispatcher option before passing to globalThis.fetch #63401, which proposed handling the same dispatcher/globalThis.fetch mismatch. Current main already covers that outcome via the runtime-fetch routing above.

    So I’m closing this as already implemented rather than keeping a duplicate issue open.

    Review notes: reviewed against 86f8c826e20a; fix evidence: release v2026.4.23, commit a9797214338b.

  2. locked as resolved and limited conversation to collaborators on Apr 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions