endojs / endo

Endo is a distributed secure JavaScript sandbox, based on SES
Apache License 2.0
804 stars 71 forks source link

SES_IMPORT_REJECTED lacks location of offending code #2430

Open dckc opened 2 weeks ago

dckc commented 2 weeks ago

Describe the bug

When I hit SES_IMPORT_REJECTED, I expect to see the file and line number of the syntax error, but all I get is a stack trace of endo code that did the rejecting.

It's like a compiler crash instead of a compiler reporting an error in the compiled code:

REJECTED from ava test("Start the contract"): (SyntaxError#2)
SyntaxError#2: Possible import expression rejected at <unknown>:7. (SES_IMPORT_REJECTED)
  at Object.execute (.../compartment-mapper/src/parse-pre-cjs.js:30:27)
  at require (.../compartment-mapper/src/parse-cjs-shared-export-wrapper.js:135:29)
  at eval (eval at <anonymous> (eval at makeEvaluate (file:///tmp/noble-hashes-app/node_modules/ses/src/make-evaluate.js:92:27)), <anonymous>:5:20)
  at Object.execute (.../compartment-mapper/src/parse-pre-cjs.js:40:1)
  at require (.../compartment-mapper/src/parse-cjs-shared-export-wrapper.js:135:29)
  at eval (eval at <anonymous> (eval at makeEvaluate (file:///tmp/noble-hashes-app/node_modules/ses/src/make-evaluate.js:92:27)), <anonymous>:4:18)
  at Object.execute (.../compartment-mapper/src/parse-pre-cjs.js:40:1)
  at eval (.../noble-hashes-app-contract/src/offer-up.contract.js:1:182)
  at async importBundle (.../import-bundle/src/index.js:57:18)

Steps to reproduce

See https://github.com/Agoric/agoric-sdk/discussions/9958#discussioncomment-10454438

Expected behavior

file, line number where the SyntaxError occurred whenever SES_IMPORT_REJECTED is thrown.

Platform environment

yarn create @agoric/dapp clones https://github.com/Agoric/dapp-offer-up , currently at b61d102 , including resolutions such as

    "@endo/bundle-source": "2.5.2-upstream-rollup",

Additional context

cc @tgrecojs

tgrecojs commented 2 weeks ago

thanks for opening! @dckc