fix: refactor createChunkTransformStream type definitions#1087
Open
odaysec wants to merge 1 commit into
Open
Conversation
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
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. |
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fix
blob/src/helpers.ts, rewritecreateChunkTransformStreamso it creates an identityTransformStream<ArrayBuffer | Uint8Array, Uint8Array>()and returnsnew ReadableStream<ArrayBuffer | Uint8Array>({...}).pipeThrough(transform), where the chunking logic is implemented in theReadableStreamsource 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 normalizechunkhandling withchunk 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.