Closed mshima closed 2 months ago
Attention: Patch coverage is 98.07692%
with 1 line
in your changes missing coverage. Please review.
Please upload report for BASE (
main@0c03959
). Learn more about missing BASE report.
Files with missing lines | Patch % | Lines |
---|---|---|
packages/core/src/lib/create-prompt.mts | 96.00% | 1 Missing :warning: |
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
In absolute, I'd prefer not adding new APIs on top of Promise
. That's also kind of hard to understand for folks new to the codebase since it's not a Node built-in. I added withResolver
as-is since it's polyfill for Node 18.
Instead of exposing onFinally
, could we keep the logic more similar to how it is, but instead of calling onExit
, we could clear the cleanups on promise.finally
? (There's a risk approaching it this way to modify the order of operations; I'm not sure without trying if it'll cause side-effects)
In absolute, I'd prefer not adding new APIs on top of
Promise
. That's also kind of hard to understand for folks new to the codebase since it's not a Node built-in. I addedwithResolver
as-is since it's polyfill for Node 18.
Since a custom CancelablePromise was implemented a custom withResolver
looks ok to me.
Instead of exposing
onFinally
, could we keep the logic more similar to how it is, but instead of callingonExit
, we could clear the cleanups onpromise.finally
? (There's a risk approaching it this way to modify the order of operations; I'm not sure without trying if it'll cause side-effects)
I’ve tried this approach but a finally()
will return a bare Promise instead of a CancelablePromise.
The difference with the Promise is that it's a polyfill https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/withResolvers
Made 2 demos of alternative to that problem #1542 and #1543 - they're not ideal, so I'd love your review and your take if you have any other ideas to improve this!
It's difficult to understand when cleanup hooks are called. I've added signal, abort and onFinally support to CancelablePromise. So the lifecycle is managed by CancelablePromise instead of cleanup callbacks.