fixup! feat(console-taming): `unhandledRejectionTrapping` after finalized
MODIFY
packages/ses/docs/lockdown.md
packages/ses/docs/lockdown.md
@@ -27,7 +27,7 @@ Each option is explained in its own section below.
| `consoleTaming` | `'safe'` | `'unsafe'` | deep stacks |
| `errorTaming` | `'safe'` | `'unsafe'` | `errorInstance.stack` |
| `errorTrapping` | `'platform'` | `'exit'` `'abort'` `'report'` `'none'` | handling of uncaught exceptions |
-| `unhandledRejectionTrapping` | `'none'` | `'exit'` `'abort'` `'report'` | handling of finalized unhandled rejections |
+| `unhandledRejectionTrapping` | `'report'` | `'report'` `'none'` | handling of finalized unhandled rejections |
| `evalTaming` | `'safeEval'` | `'unsafeEval'` `'noEval'` | `eval` and `Function` of the start compartment. |
| `stackFiltering` | `'concise'` | `'verbose'` | deep stacks signal/noise |
| `overrideTaming` | `'moderate'` | `'min'` or `'severe'` | override mistake antidote |
@@ -375,11 +375,7 @@ able to install platform-specific finalized (rather than just same-turn)
unhandled rejection trapping.
```js
-lockdown(); // defaults to 'none'
-// or
-lockdown({ unhandledRejectionTrapping: 'exit' }); // report and exit
-// or
-lockdown({ unhandledRejectionTrapping: 'abort' }); // report and drop a core dump
+lockdown(); // defaults to 'report'
// or
lockdown({ unhandledRejectionTrapping: 'report' }); // just report
// or
@@ -405,12 +401,7 @@ handler will only be triggered by unhandled rejections when they are finalized.
This enables the program to attach rejection handlers asynchronously without
triggering the SES trap handler.
-- `'platform'`: same as `'report'` for web and Node.js
- `'report'`: just report finalized unhandled rejections to the tamed console so stack traces appear.
-- `'exit'`: reports and exits on Node.js, reports and navigates away on the
- web.
-- `'abort'`: reports and aborts a Node.js process, leaving a core dump for
- postmortem analysis, reports and navigates away on the web.
- `'none'`: do not install traps for finalized unhandled rejections. Errors are
likely to appear as `{}` when they are reported by the default trap.

MODIFY
packages/ses/index.d.ts
packages/ses/index.d.ts
@@ -24,12 +24,7 @@ export interface LockdownOptions {
localeTaming?: 'safe' | 'unsafe';
consoleTaming?: 'safe' | 'unsafe';
errorTrapping?: 'platform' | 'exit' | 'abort' | 'report' | 'none';
- unhandledRejectionTrapping?:
- | 'platform'
- | 'exit'
- | 'abort'
- | 'report'
- | 'none';
+ unhandledRejectionTrapping?: 'report' | 'none';
errorTaming?: 'safe' | 'unsafe';
dateTaming?: 'safe' | 'unsafe'; // deprecated
mathTaming?: 'safe' | 'unsafe'; // deprecated

MODIFY
packages/ses/src/error/tame-console.js
packages/ses/src/error/tame-console.js
@@ -18,13 +18,13 @@ const originalConsole = console;
*
* @param {"safe" | "unsafe"} consoleTaming
* @param {"platform" | "exit" | "abort" | "report" | "none"} [errorTrapping]
- * @param {"platform" | "exit" | "abort" | "report" | "none"} [unhandledRejectionTrapping]
+ * @param {"report" | "none"} [unhandledRejectionTrapping]
* @param {GetStackString=} optGetStackString
*/
export const tameConsole = (
consoleTaming = 'safe',
errorTrapping = 'platform',
- unhandledRejectionTrapping = 'platform',
+ unhandledRejectionTrapping = 'report',
optGetStackString = undefined,
) => {
if (consoleTaming !== 'safe' && consoleTaming !== 'unsafe') {
@@ -80,11 +80,6 @@ export const tameConsole = (
const handleRejection = reason => {
// 'platform' and 'report' just log the reason.
causalConsole.error('SES_UNHANDLED_REJECTION:', reason);
- if (unhandledRejectionTrapping === 'exit') {
- globalThis.process.exit(globalThis.process.exitCode || -1);
- } else if (unhandledRejectionTrapping === 'abort') {
- globalThis.process.abort();
- }
};
// Maybe track unhandled promise rejections.
const h = makeRejectionHandlers(handleRejection);
@@ -119,12 +114,6 @@ export const tameConsole = (
) {
const handleRejection = reason => {
causalConsole.error('SES_UNHANDLED_REJECTION:', reason);
- if (
- unhandledRejectionTrapping === 'exit' ||
- unhandledRejectionTrapping === 'abort'
- ) {
- globalThis.window.location.href = `about:blank`;
- }
};
const h = makeRejectionHandlers(handleRejection);

MODIFY
packages/ses/src/lockdown-shim.js
packages/ses/src/lockdown-shim.js
@@ -162,7 +162,7 @@ export const repairIntrinsics = (options = {}) => {
errorTrapping = getenv('LOCKDOWN_ERROR_TRAPPING', 'platform'),
unhandledRejectionTrapping = getenv(
'LOCKDOWN_UNHANDLED_REJECTION_TRAPPING',
- 'platform',
+ 'report',
),
regExpTaming = getenv('LOCKDOWN_REGEXP_TAMING', 'safe'),
localeTaming = getenv('LOCKDOWN_LOCALE_TAMING', 'safe'),
@@ -303,7 +303,7 @@ export const repairIntrinsics = (options = {}) => {
optGetStackString = intrinsics['%InitialGetStackString%'];
}
const consoleRecord = tameConsole(
- // @ts-expect-error2 tameConsole does its own input validation
+ // @ts-expect-error tameConsole does its own input validation
consoleTaming,
errorTrapping,
unhandledRejectionTrapping,

fixup! feat(console-taming): `unhandledRejectionTrapping` after finalized