cloudflare / cloudflare/workers-sdk

Resolve ReadableStream types for `getPlatformProxy()`

Open
#9,972 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
4.5k
Forks
1.5k
Avg merge
3d 8h
Merged PRs (30d)
187

Description

```suggestion
// @ts-expect-error `ReadableStream` between Node.js and Workers doesn't quite along (Property 'readAtLeast' is missing in type 'import("stream/web").ReadableStreamBYOBReader')
```

This method is [non-standard](https://developers.cloudflare.com/workers/runtime-apis/streams/readablestreambyobreader/#:~:text=readAtLeast%20is%20a%20non%2Dstandard%20extension%20to%20the%20Streams%20API%20which%20allows%20users%20to%20specify%20that%20at%20least%20minBytes%20bytes%20must%20be%20read%20into%20the%20buffer%20before%20resolving%20the%20read.)

What happens if the IMAGE binding actually starts to use this?

Should we have some kind of transform/polyfill for `getPlatformProxy()`?

_Originally posted by @petebacondarwin in https://github.com/cloudflare/workers-sdk/pull/9954#discussion_r2207446897_

Contributor guide

Open the contributing guide

Research direction

Start from the getPlatformProxy() implementation and the suggested @ts-expect-error, then compare the Node.js stream/web and Workers ReadableStream types. Check how the IMAGE binding could use readAtLeast; done means the compatibility approach is defined and the resulting types work without masking the mismatch.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
api, cloud
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.