Skip to content

Fix doFinally fallback to await onFinally thenables via doAwait#511

Merged
MSNev merged 1 commit into
mainfrom
nev21/finally
May 20, 2026
Merged

Fix doFinally fallback to await onFinally thenables via doAwait#511
MSNev merged 1 commit into
mainfrom
nev21/finally

Conversation

@nev21
Copy link
Copy Markdown
Contributor

@nev21 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.

@nev21 nev21 added this to the 0.6.0 milestone May 20, 2026
@nev21 nev21 requested review from a team as code owners May 20, 2026 06:13
Copilot AI review requested due to automatic review settings May 20, 2026 06:13
@nev21 nev21 enabled auto-merge (squash) May 20, 2026 06:13
@codecov
Copy link
Copy Markdown

codecov Bot commented May 20, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.49%. Comparing base (d547a4d) to head (d3a428e).

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     
Files with missing lines Coverage Δ
lib/src/promise/await.ts 100.00% <100.00%> (+8.16%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 use doAwait(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.json with a large removal of Rollup optional/platform package entries (and fsevents).

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 packages map (only a couple of win32 entries remain here), but node_modules/rollup still declares those optionalDependencies later in the file. This makes the lockfile incomplete and can break deterministic installs (and potentially npm ci) on Linux/macOS/ARM where npm would need entries like node_modules/@rollup/rollup-linux-x64-gnu, ...-darwin-x64, etc. Please regenerate the shrinkwrap (e.g., via node common/scripts/install-run-rush.js update --full on a clean repo) and ensure all Rollup optional binary packages are consistently represented in packages.

Comment thread lib/src/promise/await.ts
Comment thread lib/src/promise/await.ts
Comment on lines 3387 to 3393
"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",
Copy link
Copy Markdown
Contributor

Copilot AI commented May 20, 2026

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:

  • www.googleapis.com
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node node install.js (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot finished work on behalf of nev21 May 20, 2026 06:37
nevware21-bot
nevware21-bot previously approved these changes May 20, 2026
Copy link
Copy Markdown
Contributor

@nevware21-bot nevware21-bot left a comment

Choose a reason for hiding this comment

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

Approved by nevware21-bot

Copy link
Copy Markdown
Contributor

Copilot AI commented May 20, 2026

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:

  • www.googleapis.com
    • Triggering command: /usr/local/bin/node node install.js (dns block)

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.
Copy link
Copy Markdown
Contributor

@nevware21-bot nevware21-bot left a comment

Choose a reason for hiding this comment

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

Approved by nevware21-bot

@MSNev MSNev enabled auto-merge (squash) May 20, 2026 17:52
@MSNev MSNev merged commit cf2f0c6 into main May 20, 2026
13 of 14 checks passed
@MSNev MSNev deleted the nev21/finally branch May 20, 2026 17:57
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.

5 participants