Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix a bug where errors could leak on extremely large stream chunks #386

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion packages/csv-stringify/dist/cjs/index.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -627,7 +627,16 @@ const stringify = function(){
callback(err);
});
stringifier.on('end', function(){
callback(undefined, chunks.join(''));
let result;
try {
result = chunks.join('');
} catch (err) {
// This can happen if the result is extremely long; it may throw
// "Cannot create a string longer than 0x1fffffe8 characters"
callback(err);
return;
}
callback(undefined, result);
});
}
if(data !== undefined){
Expand Down
11 changes: 10 additions & 1 deletion packages/csv-stringify/dist/esm/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5685,7 +5685,16 @@ const stringify = function(){
callback(err);
});
stringifier.on('end', function(){
callback(undefined, chunks.join(''));
let result;
try {
result = chunks.join('');
} catch (err) {
// This can happen if the result is extremely long; it may throw
// "Cannot create a string longer than 0x1fffffe8 characters"
callback(err);
return;
}
callback(undefined, result);
});
}
if(data !== undefined){
Expand Down
11 changes: 10 additions & 1 deletion packages/csv-stringify/dist/iife/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5688,7 +5688,16 @@ var csv_stringify = (function (exports) {
callback(err);
});
stringifier.on('end', function(){
callback(undefined, chunks.join(''));
let result;
try {
result = chunks.join('');
} catch (err) {
// This can happen if the result is extremely long; it may throw
// "Cannot create a string longer than 0x1fffffe8 characters"
callback(err);
return;
}
callback(undefined, result);
});
}
if(data !== undefined){
Expand Down
11 changes: 10 additions & 1 deletion packages/csv-stringify/dist/umd/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5691,7 +5691,16 @@
callback(err);
});
stringifier.on('end', function(){
callback(undefined, chunks.join(''));
let result;
try {
result = chunks.join('');
} catch (err) {
// This can happen if the result is extremely long; it may throw
// "Cannot create a string longer than 0x1fffffe8 characters"
callback(err);
return;
}
callback(undefined, result);
});
}
if(data !== undefined){
Expand Down
11 changes: 10 additions & 1 deletion packages/csv-stringify/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,16 @@ const stringify = function(){
callback(err);
});
stringifier.on('end', function(){
callback(undefined, chunks.join(''));
let result;
try {
result = chunks.join('');
} catch (err) {
// This can happen if the result is extremely long; it may throw
// "Cannot create a string longer than 0x1fffffe8 characters"
callback(err);
return;
}
callback(undefined, result);
});
}
if(data !== undefined){
Expand Down
13 changes: 11 additions & 2 deletions packages/csv/dist/cjs/index.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ let CsvError$1 = class CsvError extends Error {
if(Array.isArray(message)) message = message.join(' ').trim();
super(message);
if(Error.captureStackTrace !== undefined){
Error.captureStackTrace(this, CsvError$1);
Error.captureStackTrace(this, CsvError);
}
this.code = code;
for(const context of contexts){
Expand Down Expand Up @@ -2423,7 +2423,16 @@ const stringify = function(){
callback(err);
});
stringifier.on('end', function(){
callback(undefined, chunks.join(''));
let result;
try {
result = chunks.join('');
} catch (err) {
// This can happen if the result is extremely long; it may throw
// "Cannot create a string longer than 0x1fffffe8 characters"
callback(err);
return;
}
callback(undefined, result);
});
}
if(data !== undefined){
Expand Down
2 changes: 1 addition & 1 deletion packages/csv/dist/cjs/sync.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ let CsvError$1 = class CsvError extends Error {
if(Array.isArray(message)) message = message.join(' ').trim();
super(message);
if(Error.captureStackTrace !== undefined){
Error.captureStackTrace(this, CsvError$1);
Error.captureStackTrace(this, CsvError);
}
this.code = code;
for(const context of contexts){
Expand Down
13 changes: 11 additions & 2 deletions packages/csv/dist/esm/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5394,7 +5394,7 @@ let CsvError$1 = class CsvError extends Error {
if(Array.isArray(message)) message = message.join(' ').trim();
super(message);
if(Error.captureStackTrace !== undefined){
Error.captureStackTrace(this, CsvError$1);
Error.captureStackTrace(this, CsvError);
}
this.code = code;
for(const context of contexts){
Expand Down Expand Up @@ -7550,7 +7550,16 @@ const stringify = function(){
callback(err);
});
stringifier.on('end', function(){
callback(undefined, chunks.join(''));
let result;
try {
result = chunks.join('');
} catch (err) {
// This can happen if the result is extremely long; it may throw
// "Cannot create a string longer than 0x1fffffe8 characters"
callback(err);
return;
}
callback(undefined, result);
});
}
if(data !== undefined){
Expand Down
2 changes: 1 addition & 1 deletion packages/csv/dist/esm/sync.js
Original file line number Diff line number Diff line change
Expand Up @@ -5387,7 +5387,7 @@ let CsvError$1 = class CsvError extends Error {
if(Array.isArray(message)) message = message.join(' ').trim();
super(message);
if(Error.captureStackTrace !== undefined){
Error.captureStackTrace(this, CsvError$1);
Error.captureStackTrace(this, CsvError);
}
this.code = code;
for(const context of contexts){
Expand Down
13 changes: 11 additions & 2 deletions packages/csv/dist/iife/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5397,7 +5397,7 @@ var csv = (function (exports) {
if(Array.isArray(message)) message = message.join(' ').trim();
super(message);
if(Error.captureStackTrace !== undefined){
Error.captureStackTrace(this, CsvError$1);
Error.captureStackTrace(this, CsvError);
}
this.code = code;
for(const context of contexts){
Expand Down Expand Up @@ -7553,7 +7553,16 @@ var csv = (function (exports) {
callback(err);
});
stringifier.on('end', function(){
callback(undefined, chunks.join(''));
let result;
try {
result = chunks.join('');
} catch (err) {
// This can happen if the result is extremely long; it may throw
// "Cannot create a string longer than 0x1fffffe8 characters"
callback(err);
return;
}
callback(undefined, result);
});
}
if(data !== undefined){
Expand Down
2 changes: 1 addition & 1 deletion packages/csv/dist/iife/sync.js
Original file line number Diff line number Diff line change
Expand Up @@ -5390,7 +5390,7 @@ var csv_sync = (function (exports) {
if(Array.isArray(message)) message = message.join(' ').trim();
super(message);
if(Error.captureStackTrace !== undefined){
Error.captureStackTrace(this, CsvError$1);
Error.captureStackTrace(this, CsvError);
}
this.code = code;
for(const context of contexts){
Expand Down
13 changes: 11 additions & 2 deletions packages/csv/dist/umd/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5400,7 +5400,7 @@
if(Array.isArray(message)) message = message.join(' ').trim();
super(message);
if(Error.captureStackTrace !== undefined){
Error.captureStackTrace(this, CsvError$1);
Error.captureStackTrace(this, CsvError);
}
this.code = code;
for(const context of contexts){
Expand Down Expand Up @@ -7556,7 +7556,16 @@
callback(err);
});
stringifier.on('end', function(){
callback(undefined, chunks.join(''));
let result;
try {
result = chunks.join('');
} catch (err) {
// This can happen if the result is extremely long; it may throw
// "Cannot create a string longer than 0x1fffffe8 characters"
callback(err);
return;
}
callback(undefined, result);
});
}
if(data !== undefined){
Expand Down
2 changes: 1 addition & 1 deletion packages/csv/dist/umd/sync.js
Original file line number Diff line number Diff line change
Expand Up @@ -5393,7 +5393,7 @@
if(Array.isArray(message)) message = message.join(' ').trim();
super(message);
if(Error.captureStackTrace !== undefined){
Error.captureStackTrace(this, CsvError$1);
Error.captureStackTrace(this, CsvError);
}
this.code = code;
for(const context of contexts){
Expand Down