Request error `Premature close` when using API

Open
#2,785 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
38/100
Issue type
Bug
Clarity
Needs clarification
Activity status
Quiet
Tech stack
node.js, typescript
Domain
api

Research direction

Start by reproducing cloudflare.pages.projects.edit with Node 24.17.0, then trace the request and response handling associated with the Premature close error in the stack trace. Done means the edit request completes without ERR_STREAM_PREMATURE_CLOSE and the behavior is covered by a regression check.

Written by the indexing model from the issue text.

Description

Confirm this is a TypeScript library issue and not an underlying Cloudflare API issue
  • This is an issue with the TypeScript library
Describe the bug

Getting error when using cloudflare.pages.projects.edit:

FetchError: Invalid response body while trying to fetch https://api.cloudflare.com/client/v4/accounts/***/pages/projects/<PROJECT_NAME>: Premature close
    at Gunzip.<anonymous> (/home/runner/work/<some_path>/node_modules/node-fetch/lib/index.js:400:12)
    at Gunzip.emit (node:events:521:24)
    at emitErrorNT (node:internal/streams/destroy:170:8)
    at emitErrorCloseNT (node:internal/streams/destroy:129:3)
    at process.processTicksAndRejections (node:internal/process/task_queues:90:21) {
  type: 'system',
  errno: 'ERR_STREAM_PREMATURE_CLOSE',
  code: 'ERR_STREAM_PREMATURE_CLOSE'
}
To Reproduce

Use cloudflare.pages.projects.edit in Node 24.17.0

Code snippets

OS

Ubuntu

Runtime version

Typescript 6.0.3

Library version

v6.4.0

Dominant language
TypeScript
Stars
835
Forks
201
Avg merge
41m
Merged PRs (30d)
1

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from cloudflare/cloudflare-typescript

All issues in cloudflare/cloudflare-typescript

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.