Skip to content

Conversation

@TsuyoshiUshio
Copy link
Contributor

@TsuyoshiUshio TsuyoshiUshio commented Feb 5, 2026

Summary

Fixes #409 - @azure/functions@4.11.1 breaks HTTP streaming with Node.js Readable streams.

Root Cause Analysis

PR #405 (commit 81f6e9a) removed the lib.DOM dependency by replacing the BodyInit type with a locally defined HttpResponseBodyInit type. However, this new type definition only included Web API types (ReadableStream, Blob, ArrayBuffer, etc.) and did not include Node.js native Readable streams.

This caused TypeScript compilation errors for users who pass Node.js Readable streams as HTTP response bodies:

error TS2322: Type 'Readable' is not assignable to type 'HttpResponseBodyInit'.

Why this worked in v4.11.0: In v4.11.0, body was typed as BodyInit from lib.DOM. However, in user projects without lib.DOM enabled, BodyInit resolved to any, allowing any type including Readable. The v4.11.1 change to an explicit union type surfaced this incompatibility.

Why this is type-only fix: Testing confirms that Node.js 20+ Response constructor natively accepts Node.js Readable streams (via undici), so no runtime conversion is needed.

Changes

types/http.d.ts:

  • Added Readable from stream module to imports
  • Added Readable to the HttpResponseBodyInit union type
  • Updated JSDoc comment

Testing

  • All 230 existing unit tests pass
  • Verified Node.js Response accepts Readable directly: new Response(readable) works in Node.js 20+

@TsuyoshiUshio TsuyoshiUshio requested a review from a team as a code owner February 5, 2026 16:50
@swapnil-nagar
Copy link
Contributor

Add the tests to fix this and update the package.json version

Fixes #409 - adds Readable from stream module to HttpResponseBodyInit type
to support HTTP streaming scenarios with Node.js streams.
@TsuyoshiUshio TsuyoshiUshio force-pushed the tsushi/httpresponsebodyinit branch from fa85846 to db2ca2b Compare February 5, 2026 17:15
@TsuyoshiUshio
Copy link
Contributor Author

Thanks for the review! I've addressed the feedback:

  1. ✅ Added tests for Node.js Readable stream body support (2 test cases)
  2. ✅ Updated package.json version to 4.11.2
  3. ✅ Fixed lint error (changed async generator to sync generator since no await was needed)

@swapnil-nagar
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@TsuyoshiUshio TsuyoshiUshio merged commit 65aabb6 into v4.x Feb 6, 2026
13 checks passed
@TsuyoshiUshio TsuyoshiUshio deleted the tsushi/httpresponsebodyinit branch February 6, 2026 04:24
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.

@azure/functions@4.11.1 broken HttpResponseBodyInit typings

2 participants