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

Loading SES fails if globalThis.process is shimmed #1917

Closed
mhofman opened this issue Dec 30, 2023 · 0 comments · Fixed by #1923
Closed

Loading SES fails if globalThis.process is shimmed #1917

mhofman opened this issue Dec 30, 2023 · 0 comments · Fixed by #1923
Labels
bug Something isn't working kriskowal-review-2024-01 Issues that kriskowal wants to bring to the attention of the team for review as of January, 2024 ses

Comments

@mhofman
Copy link
Contributor

mhofman commented Dec 30, 2023

Describe the bug

Console taming assumes that if globalThis.process exists, then we're in node, and get to use some process APIs like .on() .exit() etc.

// Node.js
if (errorTrapping !== 'none' && globalThis.process !== undefined) {
globalThis.process.on('uncaughtException', error => {
// causalConsole is born frozen so not vulnerable to method tampering.
ourConsole.error(error);
if (errorTrapping === 'platform' || errorTrapping === 'exit') {
globalThis.process.exit(globalThis.process.exitCode || -1);
} else if (errorTrapping === 'abort') {
globalThis.process.abort();
}
});
}
if (
unhandledRejectionTrapping !== 'none' &&
globalThis.process !== undefined
) {
const handleRejection = reason => {
// 'platform' and 'report' just log the reason.
ourConsole.error('SES_UNHANDLED_REJECTION:', reason);
};
// Maybe track unhandled promise rejections.
const h = makeRejectionHandlers(handleRejection);
if (h) {
// Rejection handlers are supported.
globalThis.process.on('unhandledRejection', h.unhandledRejectionHandler);
globalThis.process.on('rejectionHandled', h.rejectionHandledHandler);
globalThis.process.on('exit', h.processTerminationHandler);
}
}

If globalThis.process is shimmed with something like {env: {FOO: 'bar'}}, then loading SES fails with globalThis.process.on is not a function.

Expected behavior

Console taming should more fully feature test the Node features it expects

Platform environment

Browser

Screenshots

image

@mhofman mhofman added bug Something isn't working ses labels Dec 30, 2023
@kriskowal kriskowal added the kriskowal-review-2024-01 Issues that kriskowal wants to bring to the attention of the team for review as of January, 2024 label Jan 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working kriskowal-review-2024-01 Issues that kriskowal wants to bring to the attention of the team for review as of January, 2024 ses
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants