Skip to content

Commit

Permalink
fix(errors): Restore support for SES 0.18.3 and prior (merge #2093)
Browse files Browse the repository at this point in the history
  • Loading branch information
kriskowal committed Feb 21, 2024
2 parents 4394e6e + c86880f commit 8b289f0
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 3 deletions.
14 changes: 11 additions & 3 deletions packages/errors/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ const missing = /** @type {const} */ ([
'details',
'Fail',
'quote',
'bare',
// As of 2024-02, the Agoric chain's bootstrap vat runs with a version of SES that
// predates addition of the 'bare' method, so we must tolerate its absence and fall
// back to quote behavior in that environment (see below).
// 'bare',
'makeAssert',
]).filter(name => globalAssert[name] === undefined);
if (missing.length > 0) {
Expand Down Expand Up @@ -61,18 +64,23 @@ const assert = (value, optDetails, optErrorContructor) =>
globalAssert(value, optDetails, optErrorContructor);
Object.assign(assert, assertions);

// As of 2024-02, the Agoric chain's bootstrap vat runs with a version of SES
// that predates the addition of the 'bare' method, so we must fall back to
// quote behavior for that environment.
const bareOrQuote = bare || quote;

export {
// assertions
assert,
// related utilities that aren't assertions
bare,
bareOrQuote as bare,
makeError,
note,
quote,
redacted,
throwRedacted,
// conventional abbreviations and aliases
bare as b,
bareOrQuote as b,
quote as q,
redacted as X,
throwRedacted as Fail,
Expand Down
1 change: 1 addition & 0 deletions packages/errors/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
"@endo/ses-ava": "^1.1.1",
"ava": "^5.3.0",
"c8": "^7.14.0",
"ses0_18_3": "npm:ses@0.18.3",
"tsd": "^0.28.1"
},
"files": [
Expand Down
8 changes: 8 additions & 0 deletions packages/errors/test/test-ses0_18_3.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import test from 'ava';
import 'ses0_18_3';

test('shim bare on ses 0.18.3', async t => {
// SES v0.18.3 predates the `bare` export.
const namespace = await import('../index.js');
t.is(namespace.bare, namespace.quote);
});
Original file line number Diff line number Diff line change
Expand Up @@ -792,3 +792,12 @@ test('should handle package "immer" source', t => {
setUseProxies: ['vn', true],
});
});

// https://github.com/endojs/endo/issues/2094
test.failing('should support export of defaulted extraction', t => {
const _ = new StaticModuleRecord(`
const { x, y = x } = globalThis;
export { x, y };
`);
t.pass();
});
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7125,6 +7125,11 @@ server-destroy@^1.0.1:
resolved "https://registry.yarnpkg.com/server-destroy/-/server-destroy-1.0.1.tgz#f13bf928e42b9c3e79383e61cc3998b5d14e6cdd"
integrity sha512-rb+9B5YBIEzYcD6x2VKidaa+cqYBJQKnU4oe4E3ANwRRN56yk/ua1YCJT1n21NTS8w6CcOclAKNP3PhdCXKYtQ==

"ses0_18_3@npm:ses@0.18.3":
version "0.18.3"
resolved "https://registry.yarnpkg.com/ses/-/ses-0.18.3.tgz#d21ac8a5eaa53c3bfde2f14fc660f4fbc4fdd6c3"
integrity sha512-deFT7cN12wE8FGDfXrZ/tUDkGofixzNl2bGc/PmF2oTAhh/x+Do6qfNhpmOMSAxnDdqtPinTcBAM94cKHvxjZg==

set-blocking@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/set-blocking/-/set-blocking-2.0.0.tgz#045f9782d011ae9a6803ddd382b24392b3d890f7"
Expand Down

0 comments on commit 8b289f0

Please sign in to comment.