Use ILambdaContext.RemainingTime to create a valid CancellationToken for AspNetCoreServer Requests
- Vorherrschende Sprache
- C#
- Sterne
- 1.7k
- Forks
- 503
- Ø Merge
- 1 T. 18 Std.
- Gemergte PRs (30 T.)
- 21
Beschreibung
### Describe the feature
Currently when a Lambda execution times out, a AspNetCore request continues to execute even if it is checking a CancellationToken parameter for cancellation.
This feature would create a new CancellationTokenSource using ILambdaContext.RemainingTime and request cancellation when remaining time reaches or nears zero. This would allow consumer code to cancel long running operations in a way that is more controlled. This would create similar functionality to how timeouts are handled in Kestrel and IIS
### Use Case
Due to upstream concurrency limitations, we sometimes have a lambda AspNetCore request timeout. Since the CancellationToken passed into the request is never cancelled, we continue to try to execute retry requests in the background if a lambda is reused.
### Proposed Solution
_No response_
### Other Information
_No response_
### Acknowledgements
- [X] I may be able to implement this feature request
- [ ] This feature might incur a breaking change
### AWS .NET SDK and/or Package version used
Amazon.Lambda.AspNetCoreServer.Hosting 1.5.0
### Targeted .NET Platform
net6.0
### Operating System and version
AmazonLinux (Lambda)
Beitragsleitfaden
Rechercherichtung
Beginne damit nachzuverfolgen, wie Amazon.Lambda.AspNetCoreServer.Hosting 1.5.0 den CancellationToken für AspNetCoreServer-Anfragen erstellt und auf ILambdaContext zugreift. Definiere das Abbruchverhalten im Zusammenhang mit ILambdaContext.RemainingTime, einschließlich des Schwellenwerts nahe null, und überprüfe anschließend, dass lang laufende Anfragen den Abbruch vor dem Lambda-Timeout beobachten und wiederverwendete Lambdas keine Hintergrund-Wiederholungen fortsetzen.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- aws, csharp
- Bereich
- api, backend, cloud
- Issue-Typ
- Feature
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100