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

Thread stack traces to console, add entangled assert #1884

Merged
merged 4 commits into from
Nov 4, 2020

Conversation

erights
Copy link
Member

@erights erights commented Oct 19, 2020

This change upgrades Agoric SDK packages to use the new SES 0.11.0, which includes the newly entangled Error, assert, and console objects, which collectively hide error details including the stack from callers, while safely revealing them to the console.

To facilitate this, the implementation of the @agoric/assert package shifts into SES, while the package remains useful as a vehicle for TypeScript definitions. All compartments that use @agoric/assert must now be endowed with the global assert.

Much of this change is mechanical, except for the assert.js module itself which may benefit from closer review.

@erights
Copy link
Member Author

erights commented Oct 19, 2020

@kriskowal , As a result of the 2nd commit I am getting the following error everywhere. Looks to me like some packager is turning some esm into cjs with require, which is then failing to require other esm. Could you some help. Thanks.


  Uncaught exception in test/unitTests/test-registrar.js

  Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /Users/markmiller/src/ongithub/agoric/agoric-sdk/node_modules/ses/src/error/assert.js
  require() of ES modules is not supported.
  require() of /Users/markmiller/src/ongithub/agoric/agoric-sdk/node_modules/ses/src/error/assert.js from /Users/markmiller/src/ongithub/agoric/agoric-sdk/packages/assert/src/assert.js is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules.
  Instead rename /Users/markmiller/src/ongithub/agoric/agoric-sdk/node_modules/ses/src/error/assert.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from /Users/markmiller/src/ongithub/agoric/agoric-sdk/node_modules/ses/package.json.

/*
// TODO Somehow, use the `assert` exported by the SES-shim
import { assert } from 'ses';
import { assert } from 'ses/src/error/assert';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will not work and we do not expect to make it work without making ses/assert part of the public API. The reason is the opposite of what you describe.

RESM operates by lowering all modules down to CommonJS (whereas SES Compartment lifts all modules up to the level of ECMAScirpt modules).

When an RESM reaches for ses, it gets a version of SES that was compiled down CommonJS by Rollup. When it reaches for ses/src/error/assert[.js] it gets the original source, RESM compiles it down to CommonJS, Node.js attempts to load the resulting .js file, but since SES has {"type": "module"}, it is expecting that file to be in ESM format, not CJS.

It should be sufficient to import ses and use the globalThis.assert here. If we need to reach for the module from source, we will have to add ses/assert to the exported modules of SES and add build rules for Rollup.

@erights
Copy link
Member Author

erights commented Oct 20, 2020

@kriskowal
Of course with the first commit hardwiring things to paths on my local file system, nothing passes under CI. Is there any way to get things working under CI ?

@erights
Copy link
Member Author

erights commented Oct 20, 2020

@warner I need to understand anylogger and how it fits into SwingSet. Thanks.

@kriskowal
Copy link
Member

kriskowal commented Oct 20, 2020 via email

@kriskowal kriskowal changed the title WIP DO NOT MERGE --- hand wired local dependency for experimenting Thread stack traces to console, add entangled assert Nov 4, 2020
@kriskowal kriskowal self-requested a review November 4, 2020 04:53
@kriskowal kriskowal marked this pull request as ready for review November 4, 2020 04:53
Comment on lines +109 to +118
* @param {*} syscall Vat's syscall object, used to access the `vatstoreGet`
* and `vatstoreSet` operations.
* @param {() => number} allocateExportID Function to allocate the next object
* export ID for the enclosing vat.
* @param valToSlotTable {*} The vat's table that maps object identities to their
* corresponding export IDs
* @param m {*} The vat's marshaler.
* @param cacheSize {number} How many virtual objects this manager should cache
* export ID for the enclosing vat.
* @param {*} valToSlotTable The vat's table that maps object identities to
* their corresponding export IDs
* @param {*} m The vat's marshaler.
* @param {number} cacheSize How many virtual objects this manager should cache
* in memory.
*
* @returns a new virtual object manager.
* @returns {*} a new virtual object manager.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@FUDCo I adjusted this to appease the linter. It appears to have become more picky.

@kriskowal kriskowal requested review from kriskowal and removed request for kriskowal November 4, 2020 04:56
@kriskowal
Copy link
Member

I’m recusing myself as a reviewer, since I’m now a coäuthor. @michaelfig Perhaps we can get your review, particularly for the TS changes.

Copy link
Member

@michaelfig michaelfig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

In case we have to revert this PR, please ensure that you Squash and Merge. Then, since the yarn.lock change is included, we will go back to the old implementation without having to pin anything explicitly.

@kriskowal kriskowal merged commit 5d4f35f into master Nov 4, 2020
@kriskowal kriskowal deleted the scratch-integrate-full branch November 4, 2020 05:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants