-
Notifications
You must be signed in to change notification settings - Fork 217
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
feat(vows): improve handling of ephemeral values #9620
Conversation
Deploying agoric-sdk with Cloudflare Pages
|
1e779cd
to
ea54d44
Compare
* @param {Watcher<T, TResult1, TResult2, C>} [watcher] | ||
* @param {C} [watcherArgs] | ||
* @returns {Promise<TResult1 | TResult2>} | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is identical to the type for watch
, minus the return line. We might consider extracting that logic and extending it, and/or using something like the PromiseToVow helper from @agoric/orchestration that should maybe live here instead:
agoric-sdk/packages/orchestration/src/internal.ts
Lines 3 to 16 in 194ac48
/** | |
* Converts a function type that returns a Promise to a function type that | |
* returns a Vow. If the input is not a function returning a Promise, it | |
* preserves the original type. | |
* | |
* @template T - The type to transform | |
*/ | |
export type PromiseToVow<T> = T extends ( | |
...args: infer Args | |
) => Promise<infer R> | |
? (...args: Args) => Vow<R> | |
: T extends (...args: infer Args) => infer R | |
? (...args: Args) => R | |
: T; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't lines 14-15 above be removed since they're redundant?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some F2-practice for you, and just a few minor things. 😉
ac14194
to
80e9d83
Compare
Co-authored-by: Michael FIG <mfig@agoric.com>
Co-authored-by: Michael FIG <mfig@agoric.com>
80e9d83
to
ff92211
Compare
asPromise
helper for unwrapping Vow|Promise
refs: #9308 ## Description - adds `asPromise` helper to `VowTools` for unwrapping `Vow|Promise`, ensuring proper handling of ephemeral promises - updates watch-utils to better handle values that are not storable durably, such as promises ### Testing Considerations This does not include tests that simulate an upgrade - only a heap zone is used in the included tests. See #9631 ### Upgrade Considerations This PR includes changes we'd like to be in the initial release of vows.
refs: #9308 ## Description - adds `asPromise` helper to `VowTools` for unwrapping `Vow|Promise`, ensuring proper handling of ephemeral promises - updates watch-utils to better handle values that are not storable durably, such as promises ### Testing Considerations This does not include tests that simulate an upgrade - only a heap zone is used in the included tests. See #9631 ### Upgrade Considerations This PR includes changes we'd like to be in the initial release of vows.
refs: #9308 ## Description - adds `asPromise` helper to `VowTools` for unwrapping `Vow|Promise`, ensuring proper handling of ephemeral promises - updates watch-utils to better handle values that are not storable durably, such as promises ### Testing Considerations This does not include tests that simulate an upgrade - only a heap zone is used in the included tests. See #9631 ### Upgrade Considerations This PR includes changes we'd like to be in the initial release of vows.
git rebase-todo ``` # Branch pc/as-vow label base-pc-as-vow pick b6b5f5f feat(vowTools): add asVow helper pick 0cdcd5f feat(vowTools): asVow should not wrap a vow as a vow label pc-as-vow reset base-pc-as-vow merge -C 0ad10c6 pc-as-vow # feat(vowTools): add asVow helper (#9577) # Branch pc/watch-utils-as-promise label base-pc-watch-utils-as-promise pick bf430a1 feat(watchUtils): add asPromise helper # To resolve conflicts in the following commit: # * In packages/vow/src/types.js, keep inbound changes and (after that) the # definition of VowTools. # * In packages/vow/test/watch-utils.test.js, keep only inbound changes and # limit them to start at "asPromise converts a vow to a promise" (i.e., # just the additions of # https://github.com/Agoric/agoric-sdk/pull/9620/files#diff-fd7cabcc7d1097036e2981c3262aa20612bec349f6e418d53324fc33b1b26946 ). pick c940d5c feat(vowTools): asPromise helper for unwrapping vows pick 8c27c67 feat(watchUtils): handle non-storables pick 3d5a3f3 feat(types): EVow pick 1c0b964 refactor: don't re-use index pick 274df18 fix(vow): clearer stored/non-stored values pick ff92211 refactor: 'extra' field for future properties label pc-watch-utils-as-promise reset base-pc-watch-utils-as-promise merge -C 8edf902 pc-watch-utils-as-promise # feat(vows): improve handling of ephemeral values (#9620) ```
refs: #9308
Description
asPromise
helper toVowTools
for unwrappingVow|Promise
, ensuring proper handling of ephemeral promisesTesting Considerations
This does not include tests that simulate an upgrade - only a heap zone is used in the included tests. See #9631
Upgrade Considerations
This PR includes changes we'd like to be in the initial release of vows.