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

Clear up uncertain await safety #6739

Merged
merged 8 commits into from
Jan 1, 2023
Merged

Clear up uncertain await safety #6739

merged 8 commits into from
Jan 1, 2023

Conversation

michaelfig
Copy link
Member

@michaelfig michaelfig commented Dec 30, 2022

closes: #6226
closes: #6227
closes: #6232
closes: #6233
closes: #6234
closes: #6235

Description

This may serve as a demonstration of idioms to honour the Jessie await rules, most interestingly:

  • rewriting while loops with nested awaits as for-await-of loops with a Jessie-style async generator.
  • transforming try with nested awaits into an async IIFE with a catch method (await (async () => { ... })().catch(e => { ... })). It's less readable, but much more explicit. 

Also, I disabled eslint's no-continue rule for the Agoric SDK.

Security Considerations

Documentation Considerations

Testing Considerations

@michaelfig michaelfig changed the title Mfig await rules Clear up uncertain await safety Dec 30, 2022
@michaelfig michaelfig force-pushed the mfig-await-rules branch 2 times, most recently from 31b48ed to 494c518 Compare December 31, 2022 03:10
Copy link
Member

@erights erights left a comment

Choose a reason for hiding this comment

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

LGTM!!!

OMG Am I happy to see this!

packages/SwingSet/src/vats/network/network.js Show resolved Hide resolved
packages/SwingSet/src/vats/network/network.js Show resolved Hide resolved
packages/agoric-cli/src/deploy.js Show resolved Hide resolved
packages/agoric-cli/src/deploy.js Outdated Show resolved Hide resolved
packages/agoric-cli/src/deploy.js Show resolved Hide resolved
@@ -367,12 +371,11 @@ export { bootPlugin } from ${JSON.stringify(absPath)};
console.info(`Loading plugin ${JSON.stringify(pluginFile)}`);
return E.get(E(pluginManager).load(pluginName, pluginOpts))
.pluginRoot;
} catch (e) {
}).catch(e => {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
}).catch(e => {
})().catch(e => {

Uh oh. A hazard of the new approach. Surprised the type checker didn't flag it, since the left operand of the .catch is a function. Any idea why not?

Copy link
Member Author

Choose a reason for hiding this comment

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

Typescript checks weren't enabled for this file. It has other type problems that I haven't addressed yet, but are likely outside the scope of this PR.

packages/agoric-cli/src/deploy.js Show resolved Hide resolved
await main(bootP, {
bundleSource: (file, options = undefined) =>
bundleSource(pathResolve(file), options),
cache,
Copy link
Member

Choose a reason for hiding this comment

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

How does dropping cache relate to the other changes of this PR?

Copy link
Member Author

Choose a reason for hiding this comment

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

That seems to be a remnant of a drive-by fix I did in my work tree. cache wasn't well-thought-out, and its (invalid) initialisation caused some unhandled rejections that worried our developers. So it's gone for now.

packages/agoric-cli/src/deploy.js Show resolved Hide resolved
packages/cosmic-swingset/src/chain-main.js Show resolved Hide resolved
@michaelfig michaelfig self-assigned this Jan 1, 2023
@michaelfig michaelfig added the automerge:no-update (expert!) Automatically merge without updates label Jan 1, 2023
@mergify mergify bot merged commit 31f768c into master Jan 1, 2023
@mergify mergify bot deleted the mfig-await-rules branch January 1, 2023 21:47
@turadg turadg mentioned this pull request Jan 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment