fix: honour HTTP_PROXY on the customFetch path#305
Merged
scottlovegrove merged 2 commits intomainfrom May 1, 2026
Merged
Conversation
PR #302 routed every Todoist-bound request through a `customFetch` to attach usage-tracking headers, which silently bypassed the SDK's native-fetch branch — the only place `EnvHttpProxyAgent` was wired up. Result: `HTTP_PROXY` / `HTTPS_PROXY` / `NO_PROXY` were ignored from 1.60.0 onwards. Attach the SDK's shared dispatcher (re-exported in @doist/todoist-sdk 10.1.0) inside `createTrackedFetch` and `fetchTodoist` whenever the underlying fetch is the real native one. Test stubs continue to skip the dispatcher to keep their captured options clean. Fixes #304. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
doistbot
reviewed
May 1, 2026
Member
doistbot
left a comment
There was a problem hiding this comment.
This PR effectively restores proxy support for corporate users by integrating the newly exposed getDefaultDispatcher from the SDK into the outbound customFetch paths. It is a crucial fix that cleanly bridges the proxy regression while keeping test stubs properly isolated. A few refinements are noted to ensure explicitly provided dispatchers aren't inadvertently overwritten, to extract the duplicated proxy-attachment logic into a shared helper, and to streamline both the test mock setups and TypeScript assertions for better maintainability.
- Fold the native-fetch check into the helper as `attachDispatcherIfNative(fetchImpl, options)`, so both call sites stop duplicating the gate. - Skip attachment if the caller already set `dispatcher` on the options — defensive against future composition; no current caller does this. - Replace the test boilerplate that swapped `globalThis.fetch` in/out via `try/finally` with `vi.spyOn(globalThis, 'fetch')`, restored through `vi.restoreAllMocks()` in `afterEach`. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
doist-release-bot Bot
added a commit
that referenced
this pull request
May 1, 2026
## [1.60.1](v1.60.0...v1.60.1) (2026-05-01) ### Bug Fixes * honour HTTP_PROXY on the customFetch path ([#305](#305)) ([e1fc71a](e1fc71a))
Contributor
|
🎉 This PR is included in version 1.60.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
@doist/todoist-sdkto10.1.0(which now publicly exportsgetDefaultDispatcher).createTrackedFetchandfetchTodoist, attach the SDK's sharedEnvHttpProxyAgentdispatcher whenever the underlying fetch is the real native one — restoringHTTP_PROXY/HTTPS_PROXY/NO_PROXYsupport on thecustomFetchpath.Fixes #304.
Why
#302 (1.60.0) routed every Todoist-bound request through a
customFetchso we could attach the usage-tracking headers. The SDK'stransport/fetch-with-retry.tsonly attaches the proxy dispatcher on its native-fetch branch — once acustomFetchis supplied, that branch is skipped, so the proxy env vars were silently dropped. This regressed every corporate-proxy user from 1.60.0 onwards.The SDK fix landed in Doist/todoist-sdk-typescript#594, shipped as 10.1.0. This PR consumes that and wires it into our two outbound paths.
Test plan
npm run type-checkcleannpm run checkclean (lint + format)npm test— 1577 passing (4 new dispatcher cases added)HTTPS_PROXY=http://localhost:8888 td todaytransits the proxyHTTPS_PROXY=http://localhost:8888 NO_PROXY=api.todoist.com td todaybypasses the proxyHTTPS_PROXY=http://localhost:8888 td auth logintoken exchange transits the proxy🤖 Generated with Claude Code