File tree 3 files changed +13
-3
lines changed
3 files changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -132,6 +132,10 @@ Since this isn't a module with tons of installs and dependent modules I hope we
132
132
133
133
## changelog
134
134
135
+ ### version 6.0.3 - published 2022-09-05
136
+
137
+ - copy-from: fix issue #136 when the _ writev mechanism was triggered with a very large number of chunks
138
+
135
139
### version 6.0.2 - published 2021-09-13
136
140
137
141
- copy-from : fix interaction with ` pg ` optional timeout mechanism
Original file line number Diff line number Diff line change @@ -40,7 +40,13 @@ class CopyStreamQuery extends Writable {
40
40
}
41
41
42
42
_writev ( chunks , cb ) {
43
- this . chunks . push ( ...chunks )
43
+ // this.chunks.push(...chunks)
44
+ // => issue #136, RangeError: Maximum call stack size exceeded
45
+ // Using hybrid approach as advised on https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/apply
46
+ const QUANTUM = 32768
47
+ for ( let i = 0 ; i < chunks . length ; i += QUANTUM ) {
48
+ this . chunks . push ( ...chunks . slice ( i , Math . min ( i + QUANTUM , chunks . length ) ) )
49
+ }
44
50
if ( this . _gotCopyInResponse ) {
45
51
return this . flush ( cb )
46
52
}
Original file line number Diff line number Diff line change @@ -103,7 +103,7 @@ describe('copy-from', () => {
103
103
} )
104
104
105
105
it ( 'correctly handle more heavy scenario' , ( done ) => {
106
- const top = 10000
106
+ const top = 130000
107
107
const chunks = [ ]
108
108
const expected = [ ]
109
109
for ( let i = 0 ; i < top ; i ++ ) {
@@ -116,7 +116,7 @@ describe('copy-from', () => {
116
116
assert . equal ( stream . rowCount , top , 'should have rowCount ' + top + ' ' )
117
117
done ( )
118
118
} )
119
- } )
119
+ } ) . timeout ( 120000 )
120
120
121
121
it ( 'test client reuse' , ( done ) => {
122
122
const fromClient = getClient ( )
You can’t perform that action at this time.
0 commit comments