Azure / Azure/azure-functions-host

Investigate if we may need to dispose of the cancellation callback registeration

Open
#8,993 0 comments 0 reactions 0 assignees View on GitHub
needs-investigation
Dominant language
C#
Stars
2k
Forks
482
Avg merge
2d 12h
Merged PRs (30d)
38

Description

Within the invocation request method (`GrpcWorkerChannel.cs`) we register a callback for the cancellation token so that we can send a cancellation request to the workers.

```csharp
if (_cancelCapabilityEnabled)
{
context.CancellationToken.Register(() => SendInvocationCancel(invocationRequest.InvocationId));
}
```

`.Register` returns a disposable - should we be disposing it?

[CancellationTokenRegistration](https://learn.microsoft.com/en-us/dotnet/api/system.threading.cancellationtokenregistration?view=net-7.0)

- [ ] Investigate to see if we should be disposing the `CancellationTokenRegistration`
- [ ] If yes, implement changes to dispose the registration once we know the request in scope has been completed

Contributor guide

Open the contributing guide

Research direction

Start in GrpcWorkerChannel.cs at the invocation request method and review the CancellationToken.Register call and its CancellationTokenRegistration documentation. Determine whether the registration remains in scope after the invocation request completes; if disposal is needed, implement it and verify the request lifecycle handles completion correctly.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
backend
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.