From db2ca2bc73ecb7cf0b65b3d0301460b7c67356f4 Mon Sep 17 00:00:00 2001 From: Tsuyoshi Ushio Date: Thu, 5 Feb 2026 09:15:09 -0800 Subject: [PATCH 1/4] Fix HttpResponseBodyInit to include Node.js Readable streams Fixes #409 - adds Readable from stream module to HttpResponseBodyInit type to support HTTP streaming scenarios with Node.js streams. --- types/http.d.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/types/http.d.ts b/types/http.d.ts index 555b192..5373544 100644 --- a/types/http.d.ts +++ b/types/http.d.ts @@ -2,6 +2,7 @@ // Licensed under the MIT License. import { Blob } from 'buffer'; +import { Readable } from 'stream'; import { ReadableStream } from 'stream/web'; import { URLSearchParams } from 'url'; import { FunctionOptions, FunctionOutput, FunctionResult, FunctionTrigger } from './index'; @@ -11,9 +12,11 @@ import { InvocationContext } from './InvocationContext'; * Represents the body types that can be used in an HTTP response. * This is a local definition to avoid dependency on lib.dom. * Compatible with Node.js native Fetch API body types. + * Includes Node.js Readable streams for HTTP streaming scenarios. */ export type HttpResponseBodyInit = | ReadableStream + | Readable | Blob | ArrayBufferView | ArrayBuffer From edbf5342b1ea2337a076d848e56ae22400154dc5 Mon Sep 17 00:00:00 2001 From: Tsuyoshi Ushio Date: Thu, 5 Feb 2026 09:26:03 -0800 Subject: [PATCH 2/4] Add tests for Node.js Readable stream body support --- test/http/HttpResponse.test.ts | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/test/http/HttpResponse.test.ts b/test/http/HttpResponse.test.ts index a5bfaa2..82f9614 100644 --- a/test/http/HttpResponse.test.ts +++ b/test/http/HttpResponse.test.ts @@ -6,6 +6,7 @@ import { Blob } from 'buffer'; import * as chai from 'chai'; import { expect } from 'chai'; import * as chaiAsPromised from 'chai-as-promised'; +import { Readable } from 'stream'; import { ReadableStream } from 'stream/web'; import { HttpResponse } from '../../src/http/HttpResponse'; @@ -366,6 +367,39 @@ describe('HttpResponse', () => { }); expect(await res.text()).to.equal('Stream content'); }); + + it('Node.js Readable stream body', async () => { + // Create a Node.js Readable stream (common for HTTP streaming scenarios) + const readable = new Readable({ + read() { + this.push('Readable '); + this.push('stream '); + this.push('content'); + this.push(null); // Signal end of stream + }, + }); + + const res = new HttpResponse({ + body: readable, + }); + expect(await res.text()).to.equal('Readable stream content'); + }); + + it('Node.js Readable stream from async generator', async () => { + // Common pattern for HTTP streaming (e.g., AI chat responses) + async function* generateChunks() { + yield 'Hello '; + yield 'from '; + yield 'stream'; + } + + const readable = Readable.from(generateChunks()); + + const res = new HttpResponse({ + body: readable, + }); + expect(await res.text()).to.equal('Hello from stream'); + }); }); describe('HttpHeadersInit types', () => { From 1d17f2a6c110e684c00db6660997768b11f92c21 Mon Sep 17 00:00:00 2001 From: Tsuyoshi Ushio Date: Thu, 5 Feb 2026 09:37:29 -0800 Subject: [PATCH 3/4] Fix lint error and bump version to 4.11.2 --- package.json | 2 +- test/http/HttpResponse.test.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index ef544a2..d883a2b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@azure/functions", - "version": "4.11.1", + "version": "4.11.2", "description": "Microsoft Azure Functions NodeJS Framework", "keywords": [ "azure", diff --git a/test/http/HttpResponse.test.ts b/test/http/HttpResponse.test.ts index 82f9614..bfe5469 100644 --- a/test/http/HttpResponse.test.ts +++ b/test/http/HttpResponse.test.ts @@ -387,7 +387,7 @@ describe('HttpResponse', () => { it('Node.js Readable stream from async generator', async () => { // Common pattern for HTTP streaming (e.g., AI chat responses) - async function* generateChunks() { + function* generateChunks() { yield 'Hello '; yield 'from '; yield 'stream'; From 269b058f9216963a19de48cc89e0d9a8c6985a1c Mon Sep 17 00:00:00 2001 From: Tsuyoshi Ushio Date: Thu, 5 Feb 2026 09:43:28 -0800 Subject: [PATCH 4/4] Update version in src/constants.ts to 4.11.2 --- src/constants.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/constants.ts b/src/constants.ts index b92e8d3..38e44a1 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -1,6 +1,6 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the MIT License. -export const version = '4.11.1'; +export const version = '4.11.2'; export const returnBindingKey = '$return';