-
Notifications
You must be signed in to change notification settings - Fork 576
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(node): deepCopy not working for large Buffers (#909)
deepCopy does not work when copying an object with a large Buffer (see test case). This causes issues when using multipartUpload with the `checkpoint` option: e.g. ```js const file = Buffer.alloc(Math.pow(2, 30) - 1); // throws RangeError in utils/deepCopy multipartUpload("name", file, {checkpoint: {file, ...}}); ```
- Loading branch information
1 parent
8e1adfd
commit f52cd2e
Showing
3 changed files
with
24 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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 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 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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
const assert = require('assert'); | ||
const { Buffer } = require('buffer'); | ||
const { deepCopy } = require('../../../lib/common/utils/deepCopy'); | ||
|
||
describe('utils/deepCopy()', () => { | ||
it('should copy big Buffers correctly', () => { | ||
// 2^30 - 1 ~ 1GB is max size on 32-bit computer | ||
// See https://nodejs.org/api/buffer.html#buffer_buffer_constants_max_length | ||
const numberBytes = Math.pow(2, 30) - 1; | ||
const obj = { | ||
buffer: Buffer.alloc(numberBytes), | ||
}; | ||
assert.deepStrictEqual(deepCopy(obj), obj); | ||
}); | ||
}); |