René's URL Explorer Experiment


Title: bug: `retry.fetch` strips headers set by HTTP client libraries · Issue #2490 · triggerdotdev/trigger.dev · GitHub

Open Graph Title: bug: `retry.fetch` strips headers set by HTTP client libraries · Issue #2490 · triggerdotdev/trigger.dev

X Title: bug: `retry.fetch` strips headers set by HTTP client libraries · Issue #2490 · triggerdotdev/trigger.dev

Description: Trigger.dev – build and deploy durable AI agents and workflows - bug: `retry.fetch` strips headers set by HTTP client libraries · Issue #2490 · triggerdotdev/trigger.dev

Open Graph Description: Trigger.dev – build and deploy durable AI agents and workflows - bug: `retry.fetch` strips headers set by HTTP client libraries · Issue #2490 · triggerdotdev/trigger.dev

X Description: Trigger.dev – build and deploy durable AI agents and workflows - bug: `retry.fetch` strips headers set by HTTP client libraries · Issue #2490 · triggerdotdev/trigger.dev

Opengraph URL: https://github.com/triggerdotdev/trigger.dev

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"bug: `retry.fetch` strips headers set by HTTP client libraries","articleBody":"### Provide environment information\n\n  System:\n    OS: Windows 11 10.0.26100\n    CPU: (24) x64 Intel(R) Core(TM) i7-14650HX\n    Memory: 21.86 GB / 63.78 GB\n  Binaries:\n    Node: 22.11.0 - C:\\Program Files\\nodejs\\node.EXE\n    npm: 10.9.0 - C:\\Program Files\\nodejs\\npm.CMD\n    bun: 1.1.38 - C:\\Program Files\\nodejs\\bun.CMD\n\n\n### Describe the bug\n\n## Summary\nThe `retry.fetch` wrapper from `@trigger.dev/sdk` doesn't preserve headers that are set by HTTP client libraries like `openapi-fetch`. This causes API requests to fail with \"Missing or incorrect Content-Type header\" errors when using retry functionality.\n\n## Environment\n- **@trigger.dev/sdk version**: [your version]\n- **Runtime**: Bun 1.1.38\n- **OS**: Windows\n- **HTTP Client**: openapi-fetch\n\n## Expected Behavior\nWhen using `retry.fetch` as a custom fetch implementation with HTTP client libraries, headers set by the client (either in initial config or middleware) should be preserved across retry attempts.\n\n## Actual Behavior\nHeaders set by HTTP client libraries are stripped during retry attempts, causing requests to fail with missing headers.\n\n## Reproduction Steps\n\n1. Create an `openapi-fetch` client with headers in config:\n```typescript\nimport createClient from \"openapi-fetch\";\nimport { retry } from \"@trigger.dev/sdk\";\n\nconst client = createClient({\n  baseUrl: \"https://api.example.com\",\n  headers: {\n    \"Authorization\": \"Bearer token\",\n    \"Content-Type\": \"application/json\",\n  },\n  fetch: retry.fetch, // Using retry.fetch\n});\n```\n\n2. Make a request that triggers a retry (e.g., to an endpoint that returns 500):\n```typescript\nconst result = await client.POST(\"/api/endpoint\", {\n  body: { data: \"test\" }\n});\n```\n\n3. Observe that the retry attempts are missing the `Authorization` and `Content-Type` headers.\n\n## Root Cause Analysis\nLooking at the `retry.fetch` source code, the issue is in the `doFetchRequest` function:\n\n```typescript\nconst response = await fetch(input, {\n  ...init,\n  headers: {\n    ...init?.headers,  // Only preserves ORIGINAL headers from init\n    \"x-retry-count\": attemptCount.toString(),\n  },\n});\n```\n\nThe retry mechanism only spreads `init?.headers` (the original headers), completely ignoring any headers that were modified by HTTP client middleware or merged by the client library.\n\n## Workaround\nWe had to create a custom fetch wrapper:\n\n```typescript\nconst retryFetchWithHeaders = async (\n  input: RequestInfo | URL,\n  init?: RequestInit\n): Promise\u003cResponse> => {\n  const headers = new Headers(init?.headers);\n  \n  // Ensure required headers are present\n  if (!headers.has('Authorization')) {\n    headers.set('Authorization', `Bearer ${API_TOKEN}`);\n  }\n  if (!headers.has('Content-Type')) {\n    headers.set('Content-Type', 'application/json');\n  }\n\n  // Convert Headers to plain object for retry.fetch\n  const headersObj: Record\u003cstring, string> = {};\n  headers.forEach((value, key) => {\n    headersObj[key] = value;\n  });\n\n  return retry.fetch(input, {\n    ...init,\n    headers: headersObj,\n  });\n};\n```\n\n## Suggested Fix\nThe `doFetchRequest` function should preserve all headers from the incoming request, not just the original `init?.headers`. Consider:\n\n```typescript\nconst response = await fetch(input, {\n  ...init,\n  headers: {\n    ...Object.fromEntries(new Headers(init?.headers).entries()),\n    \"x-retry-count\": attemptCount.toString(),\n  },\n});\n```\n\nOr better yet, use the Headers API properly to merge headers without losing any that were set by middleware.\n\n## Impact\nThis affects any HTTP client library that:\n- Sets headers in middleware (like `openapi-fetch`, `axios` interceptors, etc.)\n- Merges headers from multiple sources\n- Relies on dynamic header setting\n\n## Additional Context\nThis is particularly problematic for OpenAPI-based clients where type-safe headers and authentication are crucial for API functionality. The current behavior makes `retry.fetch` incompatible with modern HTTP client libraries.\n\n\n\n### Reproduction repo\n\nIncluded in description\n\n### To reproduce\n\nIncluded in description\n\n### Additional information\n\n_No response_","author":{"url":"https://github.com/nickwang0808","@type":"Person","name":"nickwang0808"},"datePublished":"2025-09-09T18:55:21Z","url":"https://github.com/triggerdotdev/trigger.dev/issues/2490"}

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf
route-pattern/:user_id/:repository/issues/:id(.:format)
route-controllerissues
route-actionshow
fetch-noncev2:e07fe0fd-279e-ee6e-bbb0-353b299f6b29
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idBD02:27EABE:5CD5BDC:7C073AD:6AFAD87E
html-safe-nonce19805806a1fe9bc53834a7706f68da5e0ef91fb6b58eb0bac15e132cc29058f6
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCRDAyOjI3RUFCRTo1Q0Q1QkRDOjdDMDczQUQ6NkFGQUQ4N0UiLCJ2aXNpdG9yX2lkIjoiMjAzNDg2OTgzNDkyNjk3MTAwNiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmacab6dcf7977e1661191ab6b75676df5d01ba931bf3880c273837c3a0b5a05f7c4
hovercard-subject-tagrepository:572570113
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///issues/show
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/triggerdotdev/trigger.dev/issues/2490
twitter:imagehttps://repository-images.githubusercontent.com/572570113/0ef45e42-bd78-4810-9397-4e6147be9329
twitter:cardsummary_large_image
og:imagehttps://repository-images.githubusercontent.com/572570113/0ef45e42-bd78-4810-9397-4e6147be9329
og:image:altTrigger.dev – build and deploy durable AI agents and workflows - bug: `retry.fetch` strips headers set by HTTP client libraries · Issue #2490 · triggerdotdev/trigger.dev
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None02f4c00e74911c7cd779fc232c3130cee49eb39fd0ed4bfe3eea3b82c7c18084
turbo-cache-controlno-cache
go-importgithub.com/triggerdotdev/trigger.dev git https://github.com/triggerdotdev/trigger.dev.git
octolytics-dimension-user_id95297378
octolytics-dimension-user_logintriggerdotdev
octolytics-dimension-repository_id572570113
octolytics-dimension-repository_nwotriggerdotdev/trigger.dev
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id572570113
octolytics-dimension-repository_network_root_nwotriggerdotdev/trigger.dev
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release33c41e9d150e44415272934d676dc63c57d89c3b
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/triggerdotdev/trigger.dev/issues/2490#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Ftriggerdotdev%2Ftrigger.dev%2Fissues%2F2490
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Ftriggerdotdev%2Ftrigger.dev%2Fissues%2F2490
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fissues%2Fshow&source=header-repo&source_repo=triggerdotdev%2Ftrigger.dev
Reloadhttps://github.com/triggerdotdev/trigger.dev/issues/2490
Reloadhttps://github.com/triggerdotdev/trigger.dev/issues/2490
Reloadhttps://github.com/triggerdotdev/trigger.dev/issues/2490
https://github.com/triggerdotdev/trigger.dev
New issuehttps://github.com/login?return_to=https://github.com/triggerdotdev/trigger.dev/issues/2490
New issuehttps://github.com/login?return_to=https://github.com/triggerdotdev/trigger.dev/issues/2490
bug: retry.fetch strips headers set by HTTP client librarieshttps://github.com/triggerdotdev/trigger.dev/issues/2490#top
https://github.com/nickwang0808
nickwang0808https://github.com/nickwang0808
on Sep 9, 2025https://github.com/triggerdotdev/trigger.dev/issues/2490#issue-3399577818
Sign up for freehttps://github.com/signup?return_to=https://github.com/triggerdotdev/trigger.dev/issues/2490
Sign in to commenthttps://github.com/login?return_to=https://github.com/triggerdotdev/trigger.dev/issues/2490
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.