Skip to content

🔧 fix undici erroneously grabing previous request Agents by default - #480

Merged
sebastianMindee merged 4 commits into
mainfrom
fix-undici-default-dispatcher
Aug 27, 2026
Merged

🔧 fix undici erroneously grabing previous request Agents by default#480
sebastianMindee merged 4 commits into
mainfrom
fix-undici-default-dispatcher

Conversation

@sebastianMindee

Copy link
Copy Markdown
Collaborator

Description

Types of changes

  • Docs change / refactoring / dependency upgrade
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Requires a change to the official Guide documentation.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR addresses a dispatcher-resolution bug where the SDK could accidentally reuse a foreign undici global dispatcher (e.g., the one registered by Node’s built-in fetch), leading to transport-level failures. It adds logic to only reuse the global dispatcher when it was created by the same undici copy as the SDK, otherwise falling back to a library-owned Agent.

Changes:

  • Add resolveDefaultDispatcher() in BaseSettings to ignore foreign global dispatchers and use a shared fallback Agent.
  • Add unit tests validating dispatcher selection behavior (explicit, same-copy global, foreign global, and fallback reuse).
  • Add an integration test that reproduces the failure when explicitly passing a foreign dispatcher and verifies the default client succeeds.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
tests/v2/client/foreignDispatcher.integration.ts New integration test covering foreign global dispatcher repro + expected fixed behavior.
tests/http/baseSettings.spec.ts New unit tests for dispatcher resolution logic in BaseSettings.
src/http/baseSettings.ts Implements foreign-global-dispatcher detection and fallback dispatcher creation.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/http/baseSettings.ts Outdated
Comment thread src/http/baseSettings.ts
Comment thread tests/v2/client/foreignDispatcher.integration.ts Outdated
sebastianMindee and others added 3 commits August 27, 2026 15:12
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated no new comments.

Suppressed comments (1)

Previously missed (1) — in code that hasn't changed since the last review.

src/input/urlInput.ts:6

  • There’s an extra space after the opening { in the undici import, which is inconsistent with the rest of the codebase and may trip formatting/lint rules.
import {  request, Dispatcher } from "undici";

@sebastianMindee
sebastianMindee merged commit a3f1b4f into main Aug 27, 2026
28 checks passed
@sebastianMindee
sebastianMindee deleted the fix-undici-default-dispatcher branch August 27, 2026 14:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants