Skip to content

fix(fetch): convert null init in Response.json#5540

Merged
mcollina merged 1 commit into
nodejs:mainfrom
Ram-blip:fix/response-json-null-init
Jul 13, 2026
Merged

fix(fetch): convert null init in Response.json#5540
mcollina merged 1 commit into
nodejs:mainfrom
Ram-blip:fix/response-json-null-init

Conversation

@Ram-blip

Copy link
Copy Markdown
Contributor

This relates to...

Fixes Response.json(data, null) so null is handled through ResponseInit conversion instead of being passed directly to response initialization.

Rationale

Response.json() takes an optional ResponseInit dictionary. Web IDL dictionary conversion allows null, treating dictionary members as absent so defaults apply.

Response.json() was skipping ResponseInit conversion when init was null, which caused raw null to reach initializeResponse() and throw when reading init.status.

This change routes null through the existing ResponseInit converter, matching the behavior already used by the Response constructor.

Changes

  • Always convert init with webidl.converters.ResponseInit() in Response.json().
  • Add regression coverage for Response.json(data, null) in the existing INIT_TESTS table.

Features

N/A

Bug Fixes

Fixes Response.json(data, null) throwing TypeError.

Breaking Changes and Deprecations

N/A

Status

Signed-off-by: Ram-blip <ramcruze2000@gmail.com>
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.45%. Comparing base (c7c7e7f) to head (c95b060).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5540   +/-   ##
=======================================
  Coverage   93.45%   93.45%           
=======================================
  Files         110      110           
  Lines       37376    37374    -2     
=======================================
- Hits        34928    34927    -1     
+ Misses       2448     2447    -1     

☔ View full report in Codecov by Harness.
📢 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.

@mcollina
mcollina requested a review from KhafraDev July 11, 2026 07:57

@mcollina mcollina left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

lgtm

@mcollina
mcollina merged commit c50edaf into nodejs:main Jul 13, 2026
36 checks passed
@github-actions github-actions Bot mentioned this pull request Jul 20, 2026
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.

5 participants