Skip to content

fetch(new Request(url, { body })) reports requestBytes: 0 #12

Description

@AndresL230

Summary

estimateRequestBytes (src/core/interceptor.ts:94-106) reads init.body only. When the caller constructs a Request object first and passes it to fetch, the body lives on the Request, not on a separate init argument — the SDK records 0 bytes. Common pattern in undici users and Next.js route handlers.

Fix

When the input is a Request, read input.body or input.headers.get("content-length") (the latter doesn't consume the stream).

Files

  • src/core/interceptor.ts
  • tests/interceptor.test.ts

Priority

P2 — underreports request bytes for a common modern pattern.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Polish / nice-to-havebugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions