pjfanning opened a new pull request, #1284: URL: https://github.com/apache/pekko-http/pull/1284
### Motivation `RequestTimeoutSupport` schedules a request's timeout through `materializer.scheduleOnce` and keeps the `TimeoutAccess` in `openTimeouts` until the response for that request comes back, which is when the timeout is cancelled. The stage had no `postStop`, so a connection that goes away with requests still open — the client disconnecting, the connection being aborted, or the server being torn down — left one scheduled task per open request behind. Those tasks keep the request, the timeout handler and the stage's async callback reachable for as long as the configured `request-timeout` (20 seconds by default), and firing them achieves nothing: they only invoke a callback on a stage that is already gone. ### Modification Cancel everything still in `openTimeouts` in `postStop`, using the same best-effort `clear()` the regular response path uses. ### Result Connections that end before their requests are answered no longer leave scheduled timeouts behind. ### Tests - New test in `HttpServerWithExplicitSchedulerSpec`: `RequestTimeoutSupport` is driven with probes, a request gets a timeout handler that records being called, and both sides are then completed with the request still unanswered. With the explicitly triggered scheduler the test can then let the timeout elapse and assert the handler never runs. Reverting only the `postStop` addition makes it fail. - `sbt "http-core/testOnly org.apache.pekko.http.impl.engine.server.HttpServerSpec org.apache.pekko.http.impl.engine.server.HttpServerWithExplicitSchedulerSpec"` — pass (66 tests), including the five existing request-timeout tests. - `sbt "http-core/mimaReportBinaryIssues"` — pass. - `scalafmt --mode diff-ref=upstream/main --test` — pass. ### References None — found while auditing `src/main` for resource leaks. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
