-
Notifications
You must be signed in to change notification settings - Fork 220
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
XSnap REPL #9955
Comments
I used this fairly recently, maybe a few weeks ago, what's broken about it? |
I just verified that it's working for me on master as of |
I’ve lost track of the circumstances this was originally reported on, but content that it’s working on master until we get a more specific isolation. |
Doing that runs the xsrepl at
Indeed, in xsnap package.json scripts at agoric-sdk/packages/xsnap/package.json Lines 13 to 14 in 3c66f4b
there is an entry for
Reopening. |
Attn @kriskowal @mhofman @phoddie |
Is there something Team Moddable should look at here? |
I don't think there is anything Moddable needs to do here. We just need to better handle errors thrown in evaluated commands from our repl. Arguably this should be filed as a separate issue. |
Potential fix: diff --git a/packages/xsnap/src/xsrepl.js b/packages/xsnap/src/xsrepl.js
index 3eede346bb..bfeece538b 100755
--- a/packages/xsnap/src/xsrepl.js
+++ b/packages/xsnap/src/xsrepl.js
@@ -31,7 +31,12 @@ async function main() {
* @returns {Promise<Uint8Array>}
*/
async function handleCommand(message) {
- console.log(decoder.decode(message));
+ const { success, result, error } = JSON.parse(decoder.decode(message));
+ if (success) {
+ console.log(result);
+ } else {
+ console.error(error);
+ }
return new Uint8Array();
}
@@ -50,11 +55,22 @@ async function main() {
});
function handleCommand(request) {
const command = new TextDecoder().decode(request);
- let result = compartment.evaluate(command);
- if (result === undefined) {
- result = null;
+ let result;
+ let error;
+ let success;
+ try {
+ result = compartment.evaluate(command);
+ success = true;
+ } catch (e) {
+ success = false;
+ try {
+ const {name, message, stack} = e;
+ error = {name, message, stack};
+ } catch (_e) {
+ error = String(e);
+ }
}
- issueCommand(new TextEncoder().encode(JSON.stringify(result, null, 4)).buffer);
+ issueCommand(new TextEncoder().encode(JSON.stringify({success, result, error}, null, 4)).buffer);
}
`); |
Time for a PR? |
Describe the bug
The
xsrepl
tool for debugging xsnap has been broken for some time.To Reproduce
Steps to reproduce the behavior:
yarn xsrepl
Expected behavior
This should open up a CLI REPL you can use to send commands to an xsnap process. It’s useful for debugging xsnap.
Platform Environment
5cd99eae25a3194dd04e77bc5bae23cd9ead981d
Additional context
The tool doesn’t have validation in CI so is doomed to rot. We should either delete it or CI it.
The text was updated successfully, but these errors were encountered: