Skip to content

Commit

Permalink
fix(cosmic-swingset): make REPL history numbers more robust
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelfig committed Sep 30, 2020
1 parent 0cba48f commit ed7729a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
10 changes: 6 additions & 4 deletions packages/cosmic-swingset/lib/ag-solo/vats/captp.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@ export const getCapTPHandler = (
fallback = undefined,
) => {
const chans = new Map();
const doFallback = (method, ...args) =>
E(fallback)
[method](...args)
.catch(_ => {});
const doFallback = async (method, ...args) => {
if (!fallback) {
return {};
}
return E(fallback)[method](...args);
};
const handler = harden({
onOpen(obj, meta) {
const { channelHandle, origin = 'unknown' } = meta || {};
Expand Down
8 changes: 5 additions & 3 deletions packages/cosmic-swingset/lib/ag-solo/vats/repl.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import { isPromise } from '@agoric/promise-kit';
import { E } from '@agoric/eventual-send';

import Nat from '@agoric/nat';
import makeUIAgentMakers from './ui-agent';

// A REPL-specific JSON stringify.
Expand Down Expand Up @@ -190,6 +191,7 @@ export function getReplHandler(replObjects, send, vatPowers) {
doEval(obj, _meta) {
const { number: histnum, body } = obj;
console.debug(`doEval`, histnum, body);
Nat(histnum);
if (histnum <= highestHistory) {
throw new Error(
`histnum ${histnum} is not larger than highestHistory ${highestHistory}`,
Expand Down Expand Up @@ -250,10 +252,10 @@ export function getReplHandler(replObjects, send, vatPowers) {
},

onMessage(obj, meta) {
if (handler[obj.type]) {
return handler[obj.type](obj, meta);
if (!handler[obj.type]) {
return false;
}
return false;
return handler[obj.type](obj, meta);
},
});

Expand Down
2 changes: 1 addition & 1 deletion packages/cosmic-swingset/lib/ag-solo/web.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export async function makeHTTPListener(basedir, port, host, rawInboundCommand) {
'from',
JSON.stringify(obj, undefined, 2),
);
throw (err && err.message) || JSON.stringify(err);
throw (err && err.message) || err;
});
};

Expand Down

0 comments on commit ed7729a

Please sign in to comment.