-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix edge cases constructing long stack traces
fixes #1387
- Loading branch information
1 parent
ef55076
commit 5013c07
Showing
5 changed files
with
84 additions
and
14 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,22 @@ | ||
var assert = require('assert'); | ||
var common = require('../../common'); | ||
var connection = common.createConnection({port: common.fakeServerPort}); | ||
|
||
var server = common.createFakeServer(); | ||
|
||
server.listen(common.fakeServerPort, function (err) { | ||
assert.ifError(err); | ||
|
||
// Common mistake to leave in code | ||
Error.prepareStackTrace = function (err, stack) { | ||
return stack; | ||
}; | ||
|
||
connection.query('INVALID SQL', function (err) { | ||
assert.ok(err, 'got error'); | ||
assert.ok(typeof err.stack !== 'string', 'error stack is not a string'); | ||
|
||
connection.destroy(); | ||
server.destroy(); | ||
}); | ||
}); |
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,20 @@ | ||
var assert = require('assert'); | ||
var common = require('../../common'); | ||
var connection = common.createConnection({port: common.fakeServerPort}); | ||
|
||
var server = common.createFakeServer(); | ||
|
||
server.listen(common.fakeServerPort, function (err) { | ||
assert.ifError(err); | ||
|
||
Error.stackTraceLimit = 0; | ||
|
||
connection.query('INVALID SQL', function (err) { | ||
assert.ok(err, 'got error'); | ||
assert.ok(!err.stack || err.stack.indexOf('\n --------------------\n') === -1, | ||
'error stack does not have delimiter'); | ||
|
||
connection.destroy(); | ||
server.destroy(); | ||
}); | ||
}); |
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,18 @@ | ||
var assert = require('assert'); | ||
var common = require('../../common'); | ||
var connection = common.createConnection({port: common.fakeServerPort}); | ||
|
||
var server = common.createFakeServer(); | ||
|
||
server.listen(common.fakeServerPort, function (err) { | ||
assert.ifError(err); | ||
|
||
connection.query('INVALID SQL', function (err) { | ||
assert.ok(err, 'got error'); | ||
assert.ok(typeof err.stack === 'string', 'error stack is string'); | ||
assert.ok(err.stack.indexOf('\n --------------------\n') !== -1, 'error stack has delimiter'); | ||
|
||
connection.destroy(); | ||
server.destroy(); | ||
}); | ||
}); |