Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/handlers/services/responseService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,18 @@ export class ResponseService {
));
}

if (
isResponseAlreadyMapped &&
this.context.isStreaming &&
getRuntimeKey() == 'node'
) {
finalMappedResponse = new Response(finalMappedResponse.body, {
status: finalMappedResponse.status,
statusText: finalMappedResponse.statusText,
headers: new Headers(finalMappedResponse.headers),
});
}
Comment on lines +64 to +74
Copy link

Copilot AI Mar 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This new code path (isResponseAlreadyMapped && isStreaming && node) lacks a corresponding unit test. The existing test file at tests/unit/src/handlers/services/responseService.test.ts has comprehensive tests for create() but none where isStreaming is true. Consider adding a test that sets mockRequestContext.isStreaming = true, mocks getRuntimeKey to return 'node', and verifies that updateHeaders succeeds without throwing (i.e., the cloned response has mutable headers). You could also verify the cloned response preserves status, statusText, and headers from the original.

Copilot uses AI. Check for mistakes.

this.updateHeaders(finalMappedResponse, cache.cacheStatus, retryAttempt);

return {
Expand Down