tc39 / proposal-shadowrealm

ECMAScript Proposal, specs, and reference implementation for Realms
https://tc39.es/proposal-shadowrealm/
1.43k stars 67 forks source link

Normative: fix #353 - propagate error details across realms when possible #372

Closed caridy closed 1 year ago

caridy commented 2 years ago

This PR introduces 2 normative changes (needs consensus):

[ ] CreateTypeErrorCopy abstract operation must not cause any ECMAScript code execution when creating a new message and stack. [ ] censor the error's stack if the host is providing such information inside ShadowRealms.

Refactor PR to make it simpler to recognize when an error must be copied over the callable boundary into the caller realm, whether that's a result of evaluation, importValue or just calling a wrapped function.

Additionally, this PR defines when to censor the error's stack if the host is providing such information.

caridy commented 2 years ago

/cc @littledan

ljharb commented 2 years ago

what about an AggregateError's errors?

caridy commented 2 years ago

@littledan @ljharb I have made the suggested changes.

caridy commented 2 years ago

cc @mhofman please review.

caridy commented 1 year ago

With the latest changes, this PR now covers to things:

  1. makes it simpler to recognize when an error must be copied over the callable boundary into the caller realm, whether that's a result of evaluation, importValue or just calling a wrapped function.

  2. defines when to censor the error's stack if the host is providing such information.

The explainer (https://github.com/tc39/proposal-shadowrealm/pull/381) does describe how to censor, and how to produce a message value for copied errors, to complement this PR.

caridy commented 1 year ago

Closing in favor of https://github.com/tc39/proposal-shadowrealm/pull/382