Skip to content

Preserve Win32 resources when result cleanup fails - #155

Merged
leileizhang (lei9444) merged 3 commits into
mainfrom
leilzh/win32-cleanup-recovery
Sep 15, 2026
Merged

leileizhang (lei9444) merged 3 commits into
mainfrom
leilzh/win32-cleanup-recovery

Conversation

@lei9444

@lei9444 leileizhang (lei9444) commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Keep ownership of direct-return and independent out-slot resources when native cleanup fails, instead of losing the resource while consuming its result slot.

  • Capture defined owned results before fallible result processing, including outputs converted before a later failure.
  • Retain failed cleanups in a Win32-specific CallError, with the result target, original cleanup error, shared resource owner, and explicit retry.
  • Expose DynWin32CallError on the Win32 subpaths. Its immutable cleanupFailures records and retryCleanup() remain usable after failed retries or JavaScript projection errors.
  • Prepare the finalizer-backed JavaScript error before dispatch only for plans that can produce owned return/out results. Scalar and aggregate-only plans do not allocate this recovery error.
  • Preserve exactly-once successful cleanup, resource lease checks, native side-effect ordering, and existing aggregate-field ownership. Retry never invokes the original native function again or clears native close-protection flags.

This is a focused follow-up to #152, not unsafe code generation or a COM/WinRT refactor.

README scope

Restore the root README to its exact content before #152, removing the project-wide experimental notice and the flat Win32 introduction. Keep the experimental notice only in the dedicated flat Win32 architecture document.

Compatibility

The Rust win32::CallPlan::invoke() error type is now win32::CallError, rather than the shared WinRT error type. message() and source_error() expose the original invocation error; cleanup_failures() and retry_cleanup() provide recovery. The successful CallResult shape and Win32 contract schema are unchanged.

JavaScript errors without failed cleanup retain their existing behavior. The eight WinRT/COM public JavaScript and declaration facade files remain byte-identical.

Validation

  • Core Win32: 91 passed; binding Win32: 31 passed, 1 existing optional MAPI-provider test ignored.
  • New native cases cover protected return/out handles, native success/failure, partial result conversion, partial/repeated retry, shared owner state, lease exclusion, and error destruction.
  • Test-hooks Win32 Node suite: 112 passed, including real native cleanup failure transport, projection errors, aliases, and GC. CI requires the native recovery fixture after the existing test-hooks build.
  • Production Node suite: 196 passed, 5 explicit optional skips.
  • Generated E2E: Win32 5/5, WinRT TypeScript 38/38, Classic COM 17/17.
  • x64/ARM64 production builds and PE artifact checks passed; i686/ARM64 binding checks passed. ARM64 was compiled, not executed locally.

Retain owned return and out-slot resources through result processing, expose retryable Win32 call errors in Rust and JavaScript, and preserve native owners through error transport and projection failures. Add failure, retry, alias, lease, GC, and compatibility coverage without changing WinRT or COM models.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: bfe6adcb-6e2c-4e05-86ca-83e923c28999
@github-actions

github-actions Bot commented Sep 15, 2026 •

Copy link
Copy Markdown

Mixed-language test coverage

Workflow status: ✅ Passed

Layer Lines Functions Branches/regions
Rust, including native .pyd/.node 85.74% 80.78% 85.25% regions
Python aggregate 71.06% n/a 37.9% branches
Python runtime 99.12% n/a 97.37% branches
Generated Python WinRT projections 70.05% n/a 27.07% branches
Generated Python WinRT implementations 72.29% n/a 47.04% branches
JavaScript aggregate 22.14% 25.21% 57.86% branches
JavaScript runtime 44.27% 45.76% 78.81% branches
Generated WinRT projections 22.97% 18.71% 54.94% branches
Generated WinRT implementations 48.66% 59.76% 61.14% branches
Generated Classic COM projections 11.92% 23.97% 54.2% branches

View workflow run and download full HTML/LCOV/XML reports

Restore the exact pre-PR152 root README without the flat Win32 introduction or project-wide experimental notice. Keep experimental guidance only in the dedicated flat Win32 architecture document.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: bfe6adcb-6e2c-4e05-86ca-83e923c28999
Use null-prototype recovery descriptors and retain the original native carrier if AggregateError construction or decoration fails. Add projection-independent static recovery methods and regressions for prototype pollution, nested failures, and native owner lifetime.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: bfe6adcb-6e2c-4e05-86ca-83e923c28999
@lei9444
leileizhang (lei9444) merged commit 32b706e into main Sep 15, 2026
24 checks passed
@lei9444
leileizhang (lei9444) deleted the leilzh/win32-cleanup-recovery branch September 15, 2026 14:19
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.

2 participants