This repository was archived by the owner on Mar 3, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 396
fix: File#save iterable fixes
#2293
Merged
Merged
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4365,31 +4365,6 @@ describe('File', () => { | |
| } | ||
| }); | ||
|
|
||
| it('Destroyed Readable upload should throw', async () => { | ||
| const options = {resumable: false}; | ||
|
|
||
| file.createWriteStream = () => { | ||
| throw new Error('unreachable'); | ||
| }; | ||
| try { | ||
| const readable = new Readable({ | ||
| read() { | ||
| this.push(DATA); | ||
| this.push(null); | ||
| }, | ||
| }); | ||
|
|
||
| readable.destroy(); | ||
|
|
||
| await file.save(readable, options); | ||
| } catch (e) { | ||
| assert.strictEqual( | ||
| (e as Error).message, | ||
| FileExceptionMessages.STREAM_NOT_READABLE | ||
| ); | ||
| } | ||
| }); | ||
|
|
||
| it('should save a generator with no error', done => { | ||
| const options = {resumable: false}; | ||
| file.createWriteStream = () => { | ||
|
|
@@ -4439,33 +4414,6 @@ describe('File', () => { | |
| }); | ||
| }); | ||
|
|
||
| it('should error on invalid async iterator data', done => { | ||
| const options = {resumable: false}; | ||
| file.createWriteStream = () => { | ||
| const writeStream = new PassThrough(); | ||
| let errorCalled = false; | ||
| writeStream.on('error', () => { | ||
| errorCalled = true; | ||
| }); | ||
| writeStream.on('finish', () => { | ||
| assert.ok(errorCalled); | ||
| }); | ||
| return writeStream; | ||
| }; | ||
|
|
||
| const generator = async function* () { | ||
| yield {thisIsNot: 'a buffer or a string'}; | ||
| }; | ||
|
|
||
| file.save(generator(), options, (err: Error) => { | ||
| assert.strictEqual( | ||
| err.message, | ||
| 'The "chunk" argument must be of type string or an instance of Buffer or Uint8Array. Received an instance of Object' | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is just testing Node internals. Removed. |
||
| ); | ||
| done(); | ||
| }); | ||
| }); | ||
|
|
||
| it('buffer upload should retry on first failure', async () => { | ||
| const options = { | ||
| resumable: false, | ||
|
|
||
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removing this logic as for the vast majority it would simply slow down their uploads unnecessarily. Additionally, later versions of Node.js catch this for us.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you know what versions catch this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Node 18.0.0:
Here's a simple reproduction for a REPL (anything before 18 the
console.logisn't called):