Skip to content

[TW-4918] Improve attachment download stream developer experience#731

Merged
AaronDDM merged 4 commits into
mainfrom
codex/fix-attachment-download-docs
May 11, 2026
Merged

[TW-4918] Improve attachment download stream developer experience#731
AaronDDM merged 4 commits into
mainfrom
codex/fix-attachment-download-docs

Conversation

@AaronDDM
Copy link
Copy Markdown
Collaborator

@AaronDDM AaronDDM commented May 11, 2026

Summary

  • add attachments.downloadNodeStream() as a non-breaking Node.js convenience helper that converts attachment downloads to NodeJS.ReadableStream
  • keep attachments.download() returning Web ReadableStream for Fetch-native runtimes such as Cloudflare Workers
  • use explicit node:stream imports for Node built-ins, consistent with the SDK's existing Cloudflare Workers requirement for nodejs_compat
  • update attachments.download() JSDoc to describe the actual Web Stream return type
  • add attachment resource tests for the Node stream helper
  • add an Unreleased CHANGELOG entry

Jira

Why

The v8 native Fetch migration changed Response.body to the Web Streams API. That is the right cross-runtime primitive, but Node.js production apps commonly need Node streams for pipeline(), file writes, S3 uploads, and HTTP response streaming. This PR preserves the existing API while adding an explicit Node-friendly path.

The SDK already requires Cloudflare Workers deployments to enable nodejs_compat, as shown by the existing Workers examples and top-level Node built-in usage in the SDK. Using node:stream is therefore explicit and consistent rather than introducing a new compatibility requirement.

Validation

  • npm test -- attachments.spec.ts --coverage=false
  • npm run build
  • npm run lint -- --quiet

Note: npm test -- attachments.spec.ts passes the attachment suite, but exits nonzero when coverage is enabled because this repo enforces global coverage thresholds for focused test runs.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 11, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.72%. Comparing base (f005620) to head (8f739b0).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #731   +/-   ##
=======================================
  Coverage   98.72%   98.72%           
=======================================
  Files          39       39           
  Lines         860      864    +4     
  Branches       69       69           
=======================================
+ Hits          849      853    +4     
  Misses         11       11           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@AaronDDM AaronDDM marked this pull request as ready for review May 11, 2026 15:04
@AaronDDM AaronDDM self-assigned this May 11, 2026
@AaronDDM AaronDDM requested a review from radenkovic May 11, 2026 15:05
@AaronDDM AaronDDM changed the title [codex] Fix attachment download stream docs [TW-4918] Fix attachment download stream docs May 11, 2026
@AaronDDM AaronDDM marked this pull request as draft May 11, 2026 15:06
@AaronDDM AaronDDM marked this pull request as ready for review May 11, 2026 15:10
@AaronDDM AaronDDM changed the title [TW-4918] Fix attachment download stream docs [TW-4918] Improve attachment download stream developer experience May 11, 2026
@AaronDDM AaronDDM marked this pull request as draft May 11, 2026 17:32
@AaronDDM AaronDDM marked this pull request as ready for review May 11, 2026 17:33
@AaronDDM AaronDDM marked this pull request as draft May 11, 2026 17:37
@AaronDDM AaronDDM marked this pull request as ready for review May 11, 2026 17:40
@AaronDDM AaronDDM merged commit b3a4c5b into main May 11, 2026
10 checks passed
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