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(ses): Support an incomplete shimmed globalThis.process #1923

Merged
merged 4 commits into from
Jan 8, 2024

Conversation

gibson042
Copy link
Contributor

Fixes #1917

Description

Updates packages/ses/src/error/tame-console.js to check for a globalThis.process.on function rather than assuming it when globalThis.process is defined.

Also updates general patterns for checking globalThis properties for better uniformity.

Security Considerations

n/a

Scaling Considerations

n/a

Documentation Considerations

n/a

Testing Considerations

n/a

Upgrade Considerations

n/a

@gibson042 gibson042 requested review from kriskowal and mhofman January 2, 2024 21:28
@gibson042 gibson042 changed the title fix(ses): Support an incomplete shimmed globalEnv.process fix(ses): Support an incomplete shimmed globalThis.process Jan 2, 2024
Copy link
Contributor

@mhofman mhofman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fatal-assert.js change will result in problems on non node environments.

packages/ses/src/error/tame-console.js Show resolved Hide resolved
packages/ses/src/error/fatal-assert.js Outdated Show resolved Hide resolved
@gibson042 gibson042 requested a review from mhofman January 3, 2024 01:43
Copy link
Member

@kriskowal kriskowal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With caveats. Thank you!

const globalProcess = aGlobal.process || undefined;
const globalEnv =
(typeof globalProcess === 'object' && globalProcess.env) || undefined;
if (typeof globalEnv === 'object') {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this regresses if env === null. Unlikely, I’m sure.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't given the || undefined

@@ -10,7 +10,7 @@ let abandon;
// below). Currently it only checks for the `process.abort` or `process.exit`
// found on Node. It should also sniff for a vat terminating function expected
// to be found within the start compartment of SwingSet vats. What else?
if (typeof process === 'object') {
if (process && typeof process === 'object') {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps invert the order these so we don’t get a ReferenceError if process is not defined in scope.

if (
errorTrapping !== 'none' &&
typeof globalProcess === 'object' &&
typeof globalProcess.on === 'function'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should test for existence of abort and exit as well.

@gibson042
Copy link
Contributor Author

@mhofman ready for re-review.

Copy link
Contributor

@mhofman mhofman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@kriskowal
Copy link
Member

Eager to land! Thanks.

@gibson042 gibson042 force-pushed the gibson-1917-shimmed-process branch from 25ba699 to 08cbae5 Compare January 8, 2024 15:12
@gibson042 gibson042 enabled auto-merge January 8, 2024 15:17
@gibson042 gibson042 merged commit ecac811 into master Jan 8, 2024
14 checks passed
@gibson042 gibson042 deleted the gibson-1917-shimmed-process branch January 8, 2024 15:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Loading SES fails if globalThis.process is shimmed
3 participants