-
Notifications
You must be signed in to change notification settings - Fork 74
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: Support absence of TextEncoder/TextDecoder/console #1820
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
@@ -174,6 +174,10 @@ freeze(ErrorInfo); | |||
|
|||
/** @type {MakeCausalConsole} */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please adjust the type MakeCausalConsole
to @returns {VirtualConsole | undefined}
packages/ses/src/error/console.js
Outdated
@@ -174,6 +174,10 @@ freeze(ErrorInfo); | |||
|
|||
/** @type {MakeCausalConsole} */ | |||
const makeCausalConsole = (baseConsole, loggedErrorHandler) => { | |||
if (!baseConsole) { | |||
return baseConsole; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the sake of being sounder wrt the type I suggest above, what do you think of changing this to
return baseConsole; | |
return undefined; |
? Or do I miss the intent of this code?
? console | ||
: typeof print === 'function' | ||
? // Make a good-enough console for eshost. | ||
(p => freeze({ debug: p, log: p, info: p, warn: p, error: p }))( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is a console with only these methods good enough for eshost? Is eshost likely to be the only case this code needs to accommodate?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe the answer to both questions is "yes"—this is all the simple console logging functions (i.e., those that only forward their arguments to Logger with the corresponding log level), and a superset of those potentially encountered by lockdown (log
, warn
, and error
). I've improved the comment accordingly.
a74f5d3
to
a2fd851
Compare
Fix #1819
Description
Tolerate the absence of non-ECMA-262 web platform APIs.
Security Considerations
This follows existing patterns and hardens all introduced new non-primitive values. It will result in calls to a global
print
function that would not have otherwise happened, but only when it exists andconsole
is undefined (but I believe any code capable of creating those circumstances could have overriddenconsole
anyway).Scaling Considerations
n/a
Documentation Considerations
The non-web-platform environments of
eshost
invocations are sufficiently esoteric that I don't think documentation needs updating.Testing Considerations
For similar reasons, I have not introduced new tests (although I suspect that could be done).
Upgrade Considerations
None.