Repository navigation
Fix error reporting during worker termination - #506
Open
Saúl Ponce (GalaxiasKyklos) wants to merge 2 commits into
Open
Saúl Ponce (GalaxiasKyklos) wants to merge 2 commits into
Saúl Ponce (GalaxiasKyklos) wants to merge 2 commits into
Conversation
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The newly introduced fallback path lacks deterministic test coverage.
1 open finding
What changed in this PR
Improves worker-termination error handling so pending or closing Node-API environments do not abort the process.
Changes:
- Adds termination-safe exception checks and direct-runtime fallback handling.
- Adds unit and hosted-CLR regression coverage.
- Excludes the hosted-specific regression from NativeAOT tests.
| File | Description |
|---|---|
src/NodeApi/JSError.cs |
Implements termination-safe error reporting. |
test/JSErrorTests.cs |
Tests preflight termination states. |
test/TestCases/napi-dotnet/Errors.cs |
Adds the managed regression helper. |
test/TestCases/napi-dotnet/worker_termination_during_call.js |
Exercises worker termination during a managed call. |
test/NativeAotTests.cs |
Excludes the hosted-CLR-specific scenario. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Vladimir Morozov (vmoroz)
previously approved these changes
Nov 18, 2026
Vladimir Morozov (vmoroz)
dismissed
their stale review
November 18, 2026 05:27
Approved the wrong PR by mistake.
Member
|
Saúl Ponce (@GalaxiasKyklos) , thank you for your contribution! |
Avoid constructing JavaScript error values after a Node-API environment starts terminating, and add a deterministic hosted-worker regression test.\n\nFixes microsoft#505.\n\nCo-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Cover the race where error construction throws after the environment preflight succeeds, including expected and unexpected direct ThrowError statuses.\n\nCo-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Saúl Ponce (GalaxiasKyklos)
force-pushed
the
fix-jserror-worker-termination
branch
from
November 19, 2026 17:30
175944e to
bfda637
Compare
| try | ||
| { | ||
| // Do not construct a JSError object here, because that would require a runtime context. | ||
| error = CreateErrorValueForException(exception, message); |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Fixes #505.
Summary
ThrowErrorAPI when worker termination races JavaScript error constructionTesting
dotnet test test\NodeApi.Test.csproj -f net10.0 -c Debug --filter "FullyQualifiedName~JSErrorTests"dotnet test test\NodeApi.Test.csproj -f net10.0 -c Debug --filter "FullyQualifiedName~HostedClrTests&DisplayName~napi-dotnet/errors|FullyQualifiedName~HostedClrTests&DisplayName~worker_termination_during_call"