Skip to content
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

misc types cleanup #8428

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions packages/boot/test/bootstrapTests/supports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,10 @@ export const makeRunUtils = (
return result;
};

const queueAndRun = async (deliveryThunk, voidResult = false) => {
const queueAndRun = async (
deliveryThunk: () => string | undefined,
voidResult = false,
) => {
log('queueAndRun at', cranksRun);

const kpid = await runThunk(deliveryThunk);
Expand Down Expand Up @@ -162,14 +165,14 @@ export const makeRunUtils = (
export type RunUtils = ReturnType<typeof makeRunUtils>;

/**
* @param {string} bundleDir
* @param {string} specifier
* @param {ManagerType} [defaultManagerType]
* @param bundleDir
* @param specifier
* @param [defaultManagerType]
*/
export const getNodeTestVaultsConfig = async (
bundleDir = 'bundles',
specifier = '@agoric/vm-config/decentral-itest-vaults-config.json',
defaultManagerType = 'local',
defaultManagerType = 'local' as ManagerType,
) => {
const fullPath = await importMetaResolve(specifier, import.meta.url).then(
u => new URL(u).pathname,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import {
} from '@agoric/vats/tools/board-utils.js';
import type { TestFn } from 'ava';
import { ParamChangesOfferArgs } from '@agoric/inter-protocol/src/econCommitteeCharter.js';
import { AuctionParams } from '@agoric/inter-protocol/src/auction/params.js';
import { TimerBrand } from '@agoric/time';
import { makeWalletFactoryDriver } from './drivers.ts';
import { makeSwingsetTestKit } from './supports.ts';

Expand Down Expand Up @@ -308,12 +310,11 @@ test('propose change to auction governance param', async t => {
t.like(wd.getLatestUpdateRecord(), { status: { numWantsSatisfied: 1 } });

const auctioneer = agoricNamesRemotes.instance.auctioneer;
const timerBrand = agoricNamesRemotes.brand.timer;
const timerBrand = agoricNamesRemotes.brand.timer as unknown as TimerBrand;
assert(timerBrand);

t.log('propose param change');
/* XXX @type {Partial<AuctionParams>} */
const params = {
const params: Partial<AuctionParams> = {
StartFrequency: { timerBrand, relValue: 5n * 60n },
};

Expand Down
2 changes: 0 additions & 2 deletions packages/builders/index.js
Original file line number Diff line number Diff line change
@@ -1,2 +0,0 @@
// Ambient types
import '@agoric/network/exported.js';
3 changes: 0 additions & 3 deletions packages/smart-wallet/src/invitations.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ import { InvitationHandleShape } from '@agoric/zoe/src/typeGuards.js';
import { E } from '@endo/far';
import { shape } from './typeGuards.js';

// Ambient types. Needed only for dev but this does a runtime import.
import '@agoric/zoe/exported.js';

const { Fail } = assert;

// A safety limit
Expand Down
3 changes: 0 additions & 3 deletions packages/vats/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
// @ts-check
// Ambient types
import '@agoric/zoe/exported.js';
import './src/core/types-ambient.js';

// eslint-disable-next-line import/export -- no named exports
export * from './src/types.js';
Expand Down
95 changes: 95 additions & 0 deletions patches/ses+0.18.8.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
diff --git a/node_modules/ses/src/commons.js b/node_modules/ses/src/commons.js
index 2d53725..6e385bc 100644
--- a/node_modules/ses/src/commons.js
+++ b/node_modules/ses/src/commons.js
@@ -213,6 +213,7 @@ export const weaksetAdd = uncurryThis(weaksetPrototype.add);
export const weaksetHas = uncurryThis(weaksetPrototype.has);
//
export const functionToString = uncurryThis(functionPrototype.toString);
+export const errorToString = uncurryThis(Error.prototype.toString);
//
const { all } = Promise;
export const promiseAll = promises => apply(all, Promise, [promises]);
diff --git a/node_modules/ses/src/error/tame-v8-error-constructor.js b/node_modules/ses/src/error/tame-v8-error-constructor.js
index d13744c..e6989f5 100644
--- a/node_modules/ses/src/error/tame-v8-error-constructor.js
+++ b/node_modules/ses/src/error/tame-v8-error-constructor.js
@@ -8,10 +8,12 @@ import {
arraySlice,
create,
defineProperties,
+ errorToString,
fromEntries,
reflectSet,
regexpExec,
regexpTest,
+ stringReplace,
weakmapGet,
weakmapSet,
weaksetAdd,
@@ -260,7 +262,7 @@ export const tameV8ErrorConstructor = (
if (errorTaming === 'unsafe') {
const stackString = stackStringFromSST(error, sst);
weakmapSet(stackInfos, error, { stackString });
- return `${error}${stackString}`;
+ return `${errorToString(error)}${stackString}`;
} else {
weakmapSet(stackInfos, error, { callSites: sst });
return '';
@@ -285,7 +287,7 @@ export const tameV8ErrorConstructor = (

const defaultPrepareFn = tamedMethods.prepareStackTrace;

- OriginalError.prepareStackTrace = defaultPrepareFn;
+ const originalPrepareStackTrace = OriginalError.prepareStackTrace;

// A weakset branding some functions as system prepareFns, all of which
// must be defined by this module, since they can receive an
@@ -299,8 +301,37 @@ export const tameV8ErrorConstructor = (
// Use concise methods to obtain named functions without constructors.
const systemMethods = {
prepareStackTrace(error, sst) {
- weakmapSet(stackInfos, error, { callSites: sst });
- return inputPrepareFn(error, safeV8SST(sst));
+ const stackInfo = {};
+ const safeCallSites = safeV8SST(sst);
+ let preparedStack;
+ try {
+ preparedStack = inputPrepareFn(error, safeCallSites);
+ if (preparedStack === safeCallSites) {
+ // Handle depd and similar prepareStackTrace which return the structured stack trace
+ stackInfo.callSites = sst;
+ return safeCallSites;
+ } else if (
+ typeof preparedStack === 'string' &&
+ preparedStack !== ''
+ ) {
+ stackInfo.stackString = stringReplace(preparedStack, /^[\n]+/, '');
+ } else {
+ // We just need to get to the `catch` clause
+ // eslint-disable-next-line no-throw-literal
+ throw undefined;
+ }
+ } catch (_err) {
+ if (errorTaming === 'unsafe') {
+ stackInfo.stackString = stackStringFromSST(error, sst);
+ preparedStack = `${errorToString(error)}${stackInfo.stackString}`;
+ } else {
+ stackInfo.callSites = sst;
+ }
+ } finally {
+ weakmapSet(stackInfos, error, stackInfo);
+ }
+
+ return errorTaming === 'unsafe' ? preparedStack : '';
},
};
weaksetAdd(systemPrepareFnSet, systemMethods.prepareStackTrace);
@@ -333,5 +364,7 @@ export const tameV8ErrorConstructor = (
},
});

+ InitialError.prepareStackTrace = originalPrepareStackTrace;
+
return tamedMethods.getStackString;
};