Comments (6)
Added the 1.0-blocker label. But not that we do not need a fully function debugging experience to unblock 1.0. Progress could unblock even if this bug remains open for remaining problems.
from endo.
There are two things which might help:
- we just landed an option named
errorStackMode: "allow"
(or rather we fixed it to stop breaking exceptions quite so badly). When you enable this, Error objects ought to retain their name and stack data. But it also might open up a confinement leak, as it leaves some non-standard properties on the Error prototype (which V8 needs to produce stack traces). - we're looking at a patch to the Realms shim that would attach the source of each evaluated string as a "source map". This may or may not help give more information to a debugger.. we haven't been able to test it properly yet.
The patch would look like this:
diff --git a/shim/src/evaluators.js b/shim/src/evaluators.js
index 8b4fe9a..0e0fc32 100644
--- a/shim/src/evaluators.js
+++ b/shim/src/evaluators.js
@@ -94,6 +94,8 @@ export function createSafeEvaluatorFactory(unsafeRec, safeGlobal) {
const safeEval = {
eval(src) {
src = `${src}`;
+ const sourceURL = `data:,${encodeURIComponent(src)}`;
+ src += `\n//# sourceURL='${sourceURL}'\n`;
rejectImportExpressions(src);
scopeHandler.allowUnsafeEvaluatorOnce();
let err;
It wants to live in Realms, but we might also be able to add it to SES instead. Also it kinda wants to be provided as a third argument to the r.evaluate()
or SES.confine()
call (the first is the source code, the second is the endowments, and the third would be an options bundle, of which sourceURL:
or source:
could include this stuff).
What we learned about errorStackMode
is that our default (which deletes the non-standard properties from Error) breaks exception rendering pretty badly: Node.js at least doesn't show anything, not even the name and message of the exception. Your process just terminates abruptly with a line that says undefined
. So my current advice is that if your process is exiting this way, change your code to use SES.makeSESRootRealm({errorStackMode: 'allow'})
until you fix the problem, then turn that back off again before you let it run untrusted code.
The other thing we learned is that there are a lot of eval()
going on, so the stack traces usually point at line numbers inside anonymous strings. If you happen to stash a copy of the string you pass into r.evaluate()
, then the line number ought to match up with that, but in a lot of cases that string is thrown away. This will hopefully get better when we implement more of a module loader, so you can pass a module or a filename into evaluate()
or confine()
, in which case the eval'ed source code can point to a file, from which line numbers can come. The tricky bit is that we must make sure this doesn't lead to a confinement leak: a process should not be able to learn the contents of an external file by throwing an exception, and an exception on one side of a trust boundary should not reveal excess information to a caller on the other side.
And debugging, in general, is a special power, which should come from the top-most "primal" realm, and get virtualized as you make new realms inside that. We have some old E work on this to draw from, but it'll be a while before we get this figured out in the JS context.
from endo.
Monte draws from that E work: exceptions are sealed and a special debugging power, unsealException, is passed to the top-level main entry point.
Monte's trace
facility also has the power to unseal exceptions. (that's perhaps more relevant to #148 on console.log ...)
from endo.
@michaelfig does the technique in Agoric/SwingSet#158 apply here, by chance?
from endo.
It does, insofar as the filename is attached via a sourceURL to the string you're evaluating. This is the "module loader provides URLs" solution.
from endo.
SES now carries sourceURL and has taming options for errors. Please reopen if this issue is still relevant.
from endo.
Related Issues (20)
- support subpath pattern exports
- Add a note about required `compilerOptions.lib` or `compilerOptions.target` to SES readme
- Compartment mapper should take first matching of conditional exports HOT 1
- drop matrix from the lint job
- "Checker" parameters would be more ergonomic as "Rejectors" HOT 6
- cli: Add `copy` command
- cli: Add common command aliases
- Daemon: Guests able to evaluate, makeBundle, storeValue, and storeBlob
- `endo make` leaves behind temp bundle if `make()` result is bad HOT 1
- Generate bundles with untransformed original sources instead of precompiled sources.
- Document CopySet/CopyTagged
- Make `void` HOT 4
- custom parser support
- feat(compartment-mapper): Collect unused module descriptors
- Time to switch CI from Node 21 to Node 22?
- atob() return is not limited to ASCII HOT 1
- Promise Kit Empty README
- importing @endo/errors without importing SES HOT 1
- compartment-mapper build fails with pnpm
- ses: source maps
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from endo.