Skip to content

Give the dev-middleware fetch mock its status text, and state its limits - #60413

Merged
cortinico merged 1 commit into
react:mainfrom
expo:@ide/dev-middleware-fetch-mock-status-text
Dec 4, 2026
Merged

cortinico merged 1 commit into
react:mainfrom
expo:@ide/dev-middleware-fetch-mock-status-text

Conversation

@ide

@ide ide commented Nov 30, 2026

Copy link
Copy Markdown
Contributor

Summary:

Follow-up to #60362, from review notes there. The HTTPS fetch mock in packages/dev-middleware/src/__tests__/FetchUtils.js answers with undici's request, so these tests no longer exercise Node's own fetch over HTTPS; this keeps the mock closer to it:

  • The Response now has a status text, from http.STATUS_CODES. It was empty, and Device.js puts statusText in the error it reports for a failed fetch.
  • A comment states what the mock leaves out: redirects, Request objects and headers, and a 204 or 304 response, which throws because such a Response cannot have a body. The tests call it with a URL and get bodies only.

Changelog:

[INTERNAL] [CHANGED] - Give the dev-middleware HTTPS fetch mock a status text and document its limits

Test Plan:

On Node 26.12.0, yarn jest --runInBand packages/dev-middleware passes. ESLint and Prettier pass on the changed file.

The HTTPS fetch mock from react#60362 built its `Response` from the status and
body only, so `statusText` was empty and an error message that includes it
(`Device.js`) would end in a blank. It now takes the text from
`http.STATUS_CODES`. A comment states what the mock does not do: it follows
no redirects, takes no `Request` object, keeps no headers, and throws for a
204 or 304 response, which cannot have a body.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Nov 30, 2026
@ide
ide marked this pull request as ready for review November 30, 2026 23:10
@facebook-github-tools facebook-github-tools Bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Nov 30, 2026
@cortinico
cortinico merged commit b936708 into react:main Dec 4, 2026
103 of 106 checks passed
@ide
ide deleted the @ide/dev-middleware-fetch-mock-status-text branch December 4, 2026 11:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants