Fix: inject CancellationToken from request context in static commands - #2100
Merged
Conversation
Copilot
AI
changed the title
[WIP] Fix serialization issue when calling async methods with CancellationToken
Fix: inject CancellationToken from request context in static commands
Aug 23, 2026
exyi
approved these changes
Aug 28, 2026
exyi
marked this pull request as ready for review
August 28, 2026 12:36
…request context Co-authored-by: tomasherceg <5599524+tomasherceg@users.noreply.github.com> Fixed-by: Standa Lukeš
exyi
force-pushed
the
copilot/fix-static-command-serialization-issue
branch
from
August 28, 2026 13:11
1c7ddce to
6941f59
Compare
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.
Calling a static command method with a
CancellationTokenparameter caused a serialization crash (NotSupportedException: Serialization and deserialization of 'System.IntPtr' instances is not supported) because the binding compiler tried to serializeCancellationToken.Noneas a JSON constant. Since DotVVM bindings have no mechanism to supply aCancellationTokenfrom the client, it should always come from the server's request context.Changes
StaticCommandParameterType– AddedCurrentCancellationToken = 5enum value.StaticCommandMethodTranslator– InCreateExecutionPlan, detectCancellationToken-typed arguments before the constant/default check and emitCurrentCancellationTokenplan entries. These are excluded from the client-side JS args array.StaticCommandExecutionPlanSerializer– SerializeCurrentCancellationTokenasnull(likeDefaultValue); deserialize back to anull-arg plan entry.StaticCommandExecutor– ResolveCurrentCancellationTokenparameters tocontext.RequestAbortedat invocation time.Example
The
CancellationTokenargument is detected at compile time, stripped from the client payload, and re-injected server-side fromIDotvvmRequestContext.RequestAborted.