-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SERVER-35154 Propagate JS exceptions through ScopedThread#join().
This makes it so that if the ScopedThread exited due to an uncaught JavaScript exception, then calling .join() or .returnData() on it throws a JavaScript exception with the error message and stacktrace intact.
- Loading branch information
Showing
13 changed files
with
482 additions
and
96 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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,35 @@ | ||
/** | ||
* Test that $where fails gracefully when user-provided JavaScript code throws and that the user | ||
* gets back the JavaScript stacktrace. | ||
* | ||
* @tags: [ | ||
* requires_non_retryable_commands, | ||
* requires_scripting, | ||
* ] | ||
*/ | ||
(function() { | ||
"use strict"; | ||
|
||
const collection = db.where_tolerates_js_exception; | ||
collection.drop(); | ||
|
||
assert.commandWorked(collection.save({a: 1})); | ||
|
||
const res = collection.runCommand("find", { | ||
filter: { | ||
$where: function myFunction() { | ||
return a(); | ||
} | ||
} | ||
}); | ||
|
||
assert.commandFailedWithCode(res, ErrorCodes.JSInterpreterFailure); | ||
assert(/ReferenceError/.test(res.errmsg), | ||
() => "$where didn't failed with a ReferenceError: " + tojson(res)); | ||
assert(/myFunction@/.test(res.errmsg), | ||
() => "$where didn't return the JavaScript stacktrace: " + tojson(res)); | ||
assert(!res.hasOwnProperty("stack"), | ||
() => "$where shouldn't return JavaScript stacktrace separately: " + tojson(res)); | ||
assert(!res.hasOwnProperty("originalError"), | ||
() => "$where shouldn't return wrapped version of the error: " + tojson(res)); | ||
})(); |
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
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
Oops, something went wrong.