Skip to content

feat: export getDefaultDispatcher#594

Merged
scottlovegrove merged 1 commit into
mainfrom
scottl/export-dispatcher
May 1, 2026
Merged

feat: export getDefaultDispatcher#594
scottlovegrove merged 1 commit into
mainfrom
scottl/export-dispatcher

Conversation

@scottlovegrove

Copy link
Copy Markdown
Contributor

Summary

  • Re-exports getDefaultDispatcher from src/transport/http-dispatcher so it is part of the public SDK surface.

Why

Consumers that opt into the customFetch option (e.g. to attach extra request headers) currently bypass the SDK's native-fetch branch in transport/fetch-with-retry.ts, which is the only place EnvHttpProxyAgent is wired up. As a result, those consumers silently lose HTTP_PROXY / HTTPS_PROXY / NO_PROXY support.

This was just hit in the wild by todoist-cli — see Doist/todoist-cli#304. The CLI worked around it by re-implementing getDefaultDispatcher locally and adding undici as a direct dependency. Exporting the helper from the SDK lets the CLI (and any other customFetch consumer) drop that copy and reuse a single shared dispatcher instance.

Test plan

  • npm test — 571 passing, no new tests needed (existing coverage in src/transport/http-dispatcher.test.ts already exercises the function).
  • npm run check — lint + format clean.
  • npm run buildgetDefaultDispatcher appears in dist/esm/index.js, dist/cjs/index.js, and dist/types/index.d.ts.
  • Type-check status unchanged from main (the 4 pre-existing errors in app-installations, apps, and ui-extensions test fixtures are not related to this PR).

🤖 Generated with Claude Code

Lets consumers wrapping fetch (e.g. via the `customFetch` option) reuse
the SDK's `EnvHttpProxyAgent` instead of building their own, so
`HTTP_PROXY` / `HTTPS_PROXY` / `NO_PROXY` are honoured on the wrapped
path too.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@scottlovegrove scottlovegrove self-assigned this May 1, 2026
@scottlovegrove scottlovegrove requested a review from gnapse May 1, 2026 15:52

@doistbot doistbot 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.

This PR exposes getDefaultDispatcher from the SDK to help consumers using customFetch retain proxy support. It is a valuable update that will simplify workarounds for tools like the CLI while ensuring consistent connection handling. However, there are a couple of considerations regarding the risk of exposing a shared internal singleton that external consumers might unintentionally close, as well as the need for a top-level smoke test to verify the public export.

Share FeedbackReview Logs

Comment thread src/index.ts
Comment thread src/index.ts
@scottlovegrove scottlovegrove merged commit 1dad069 into main May 1, 2026
3 checks passed
@scottlovegrove scottlovegrove deleted the scottl/export-dispatcher branch May 1, 2026 16:00
doist-release-bot Bot added a commit that referenced this pull request May 1, 2026
## [10.1.0](v10.0.0...v10.1.0) (2026-05-01)

### Features

* export getDefaultDispatcher ([#594](#594)) ([1dad069](1dad069))
@doist-release-bot

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 10.1.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants