Fix doFinally fallback to await onFinally thenables via doAwait#511
Conversation
nev21
commented
May 20, 2026
- Refactors the fallback branch of doFinally (for promise-like values without native finally) to reuse doAwait instead of manually checking isPromiseLike and chaining then.
- Preserves ES2018 finally semantics by waiting for the onFinally result before propagating the original fulfillment value or rejection reason.
- Reduces duplicated logic across success and error paths in the simulated finally implementation.
- Adds a narrow type assertion on the value.then(...) assignment to satisfy TypeScript inference for the mixed promise-like return type while keeping behavior unchanged.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #511 +/- ##
==========================================
+ Coverage 96.96% 97.49% +0.53%
==========================================
Files 27 27
Lines 1450 1438 -12
Branches 341 337 -4
==========================================
- Hits 1406 1402 -4
+ Misses 44 36 -8
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR refactors doFinally()’s polyfilled finally behavior (for promise-like values that don’t implement .finally) to reuse the existing doAwait() helper so that finallyFn() results (including thenables) are awaited before propagating the original fulfillment value or rejection reason.
Changes:
- Refactor
doFinally()’s fallback implementation to usedoAwait(finallyFn(), ...)in both fulfillment and rejection paths. - Add a type assertion on the fallback
.then(...)return to satisfy TypeScript inference. - Update the Rush
npm-shrinkwrap.jsonwith a large removal of Rollup optional/platform package entries (andfsevents).
Reviewed changes
Copilot reviewed 1 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
lib/src/promise/await.ts |
Refactors doFinally() fallback logic to reuse doAwait() when .finally is unavailable. |
common/config/rush/npm-shrinkwrap.json |
Alters the lockfile content, including removal of many Rollup optional binary package entries. |
Files not reviewed (1)
- common/config/rush/npm-shrinkwrap.json: Language not supported
Comments suppressed due to low confidence (1)
common/config/rush/npm-shrinkwrap.json:827
- The shrinkwrap removes most of Rollup’s platform-specific optional binary packages from the
packagesmap (only a couple of win32 entries remain here), butnode_modules/rollupstill declares those optionalDependencies later in the file. This makes the lockfile incomplete and can break deterministic installs (and potentiallynpm ci) on Linux/macOS/ARM where npm would need entries likenode_modules/@rollup/rollup-linux-x64-gnu,...-darwin-x64, etc. Please regenerate the shrinkwrap (e.g., vianode common/scripts/install-run-rush.js update --fullon a clean repo) and ensure all Rollup optional binary packages are consistently represented inpackages.
| "node_modules/fs.realpath": { | ||
| "version": "1.0.0", | ||
| "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", | ||
| "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==" | ||
| }, | ||
| "node_modules/fsevents": { | ||
| "version": "2.3.3", | ||
| "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", | ||
| "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", | ||
| "hasInstallScript": true, | ||
| "optional": true, | ||
| "os": [ | ||
| "darwin" | ||
| ], | ||
| "engines": { | ||
| "node": "^8.16.0 || ^10.6.0 || >=11.0.0" | ||
| } | ||
| }, | ||
| "node_modules/function-bind": { | ||
| "version": "1.1.2", |
|
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
nevware21-bot
left a comment
There was a problem hiding this comment.
Approved by nevware21-bot
|
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
- Refactors the fallback branch of doFinally (for promise-like values without native finally) to reuse doAwait instead of manually checking isPromiseLike and chaining then. - Preserves ES2018 finally semantics by waiting for the onFinally result before propagating the original fulfillment value or rejection reason. - Reduces duplicated logic across success and error paths in the simulated finally implementation. - Adds a narrow type assertion on the value.then(...) assignment to satisfy TypeScript inference for the mixed promise-like return type while keeping behavior unchanged.
nevware21-bot
left a comment
There was a problem hiding this comment.
Approved by nevware21-bot