Skip to content

fix: refactor createChunkTransformStream type definitions#1087

Open
odaysec wants to merge 1 commit into
vercel:mainfrom
odaysec:patch-1
Open

fix: refactor createChunkTransformStream type definitions#1087
odaysec wants to merge 1 commit into
vercel:mainfrom
odaysec:patch-1

Conversation

@odaysec

@odaysec odaysec commented Jul 19, 2026

Copy link
Copy Markdown

fix blob/src/helpers.ts, rewrite createChunkTransformStream so it creates an identity TransformStream<ArrayBuffer | Uint8Array, Uint8Array>() and returns new ReadableStream<ArrayBuffer | Uint8Array>({...}).pipeThrough(transform), where the chunking logic is implemented in the ReadableStream source and then piped through the transform.
However, that would be a larger refactor. A smaller and behavior-preserving fix is to align the constructor generics with the declared return and chunk usage: construct new TransformStream<ArrayBuffer | Uint8Array, Uint8Array>({...}) and normalize chunk handling with chunk instanceof Uint8Array ? chunk : new Uint8Array(chunk). This removes signature ambiguity and keeps the same output/progress behavior.

Refferences
Function calls in JavaScript may pass an arbitrary number of arguments to the invoked function. If the invoked function declares fewer parameters than arguments were passed, the remaining arguments can only be accessed through the arguments object. Hence, if a function is passed too many arguments but does not use the arguments object, the remaining arguments are useless. Such calls often indicate incomplete refactorings, or may point to a misunderstanding of the functionality of the invoked function.

  • Ecma International, ECMAScript Language Definition, 5.1 Edition, Section 10. ECMA, 2011.
  • CWE-685

fix here (without changing behavior): in `packages/blob/src/helpers.ts`, rewrite `createChunkTransformStream` so it creates an identity `TransformStream<ArrayBuffer | Uint8Array, Uint8Array>()` and returns `new ReadableStream<ArrayBuffer | Uint8Array>({...}).pipeThrough(transform)`, where the chunking logic is implemented in the `ReadableStream` source and then piped through the transform.  
However, that would be a larger refactor. A smaller and behavior-preserving fix is to align the constructor generics with the declared return and chunk usage: construct `new TransformStream<ArrayBuffer | Uint8Array, Uint8Array>({...})` and normalize `chunk` handling with `chunk instanceof Uint8Array ? chunk : new Uint8Array(chunk)`. This removes signature ambiguity and keeps the same output/progress behavior.


### Refferences
Function calls in JavaScript may pass an arbitrary number of arguments to the invoked function. If the invoked function declares fewer parameters than arguments were passed, the remaining arguments can only be accessed through the arguments object. Hence, if a function is passed too many arguments but does not use the arguments object, the remaining arguments are useless. Such calls often indicate incomplete refactorings, or may point to a misunderstanding of the functionality of the invoked function.

- Ecma International, ECMAScript Language Definition, 5.1 Edition, Section 10. ECMA, 2011.
- CWE-685
@vercel

vercel Bot commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

@odaysec is attempting to deploy a commit to the Curated Tests - Permanent E2E Team on Vercel.

A member of the Team first needs to authorize it.

@changeset-bot

changeset-bot Bot commented Jul 19, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: f9349a0

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

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.

1 participant