You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 93ff8ff
Browse filesBrowse the repository at this point in the historyBrowse files
authored
fix: support cancellation during sandbox execution (#275)
## Summary
Related to #9.
Expose independently owned native interruption handles through the Rust
backend abstraction and .NET FFI. Add `Sandbox.Run(string,
CancellationToken)` and make `RunAsync` forward cancellation into
running guest execution, while preserving `Run(string)`.
Cancellation uses a dedicated interruption worker, retries the
transition into guest execution, and waits for native execution and
cancellation work to finish before returning. The callback never
accesses mutable sandbox state or acquires the execution gate. Existing
snapshot/restore behavior permits reuse after interruption.
There is no implicit SDK deadline: hosts can supply a timeout-backed
`CancellationTokenSource`. Runtime initialization and host callbacks
cannot be interrupted; host tools need their own cancellation policy.
## Validation
Executed in Ubuntu x64 containers on a KVM-capable host using .NET SDK
10.0.403 and Rust 1.94. The net8.0 tests ran with
`DOTNET_ROLL_FORWARD=Major`.
- Before the implementation: `dotnet vstest
src/sdk/dotnet/core/Tests/HyperlightSandbox.Tests/bin/Debug/net8.0/HyperlightSandbox.Tests.dll
--TestCaseFilter:FullyQualifiedName~JavaScript_RunAsync_CancellationDuringExecution_StopsGuestAsync
--Logger:"console;verbosity=normal"` **failed as expected** after a
genuine warm-up and five seconds of guest execution: expected
`OperationCanceledException`, but none was thrown.
- `just wasm guest-build` — **passed**, building the actual Python/Wasm
guest.
- `just fmt` and `just fmt-check` — **passed**.
- `just lint-rust` and `just dotnet lint-rust` — **passed**.
- `dotnet build
src/sdk/dotnet/core/Tests/HyperlightSandbox.Tests/HyperlightSandbox.Tests.csproj
--nologo -p:TreatWarningsAsErrors=true` — **passed**, zero
warnings/errors.
- `just test-rust` — **passed**, 144 unit tests and 5 HTTP integration
tests; one existing documentation example remains ignored.
- `just dotnet test-rust` — **passed**, 78 FFI tests.
- `dotnet vstest
src/sdk/dotnet/core/Tests/HyperlightSandbox.Tests/bin/Debug/net8.0/HyperlightSandbox.Tests.dll
--Logger:"console;verbosity=normal"` — **passed**, all 147 tests,
including real JavaScript immediate/timer cancellation and recovery,
pre-canceled execution, isolation from completed cancellation
registrations, and Python/Wasm interruption followed by snapshot
restoration.
The first Rust HTTP run failed because a network-disabled container
could not resolve the existing HTTPS test's destination. The full Rust
suite passed when run with its required networking. FFI and .NET guest
tests remained resource-limited and network-disabled.
Windows execution, the Python SDK suite, and package publishing were not
run locally; upstream CI remains pending. This PR must remain a draft.
## AI assistance
Copilot assisted with implementation, tests, documentation, and this
description.
---------
Signed-off-by: Vincent Biret <vibiret@microsoft.com>
Signed-off-by: James Sturtevant <jsturtevant@gmail.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: James Sturtevant <jsturtevant@gmail.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot-Session: 3d6807e7-70a6-4c43-8dc1-7bab20376cd4
0 commit comments