Repository navigation
Allow stateful HTTP endpoints to recover after DELETE - #307
EhsanAzish80 wants to merge 3 commits into
Conversation
varun06
left a comment
There was a problem hiding this comment.
Thanks @EhsanAzish80, the Server.stop() change is a real fix. Reverting just that part makes the slow-session test fail. I ran the new tests many times locally with no flakes, and the suite passes.
Two things before merging, since this becomes the recommended production API:
- Validate before creating the session. The validation pipeline (Origin, bearer auth, Accept/Content-Type) only runs inside
transport.handleRequest, afterserverFactoryandserver.start. With aBearerTokenValidator, aninitializewithout a token correctly gets a 401, but aServerhas already been built and started (factory called once). Could the manager runvalidationPipeline.validate(...)on the initialize request before calling the factory? - Limit the number of sessions. Each initialize creates a
Serverthat lives up tosessionTimeout
(1h by default). AmaxSessionsoption that rejects new sessions with 503 would avoid unbounded growth.
Smaller, non-blocking:
lastAccessedAtonly updates on incoming requests, so a client holding a GET stream open without
POSTs gets stopped mid-stream after the timeout.removeExpiredSessions()awaitsserver.stop()inside the request path; the 60s cleanup task already
covers it.- The 500 body includes the factory's
localizedDescription; a generic message plus a log entry would be safer. - Worth a release note that
Server.stop()now cancels in-flight handlers for all transports. - Tests for expiry, a failed DELETE, and a throwing factory would round this out.
9eae4c8 to
ec9d423
Compare
|
Updated this for the two review points: initialize now runs validation before the server factory, and |
|
Thanks @EhsanAzish80, both points are addressed. One thing left: Also worth deciding on the default Smaller, non-blocking: the manager repeats the transport's default validator list (a shared static default |
|
Thanks Varun, I updated #307 in The 5 focused session manager tests and all 566 Swift tests passed locally. The new session tests also passed in Ubuntu CI, and macOS, conformance, docs, and Linux static build are green. The Ubuntu test job hit 60-second limits in AI helped write the new tests; I ran them. |
Fixes #286 for stateful HTTP endpoints. The session manager creates a fresh server and transport for each initialize. DELETE stops the old server and lets the client initialize a new session.
Initialize is validated before the server factory runs, then handed to the transport without validating it a second time.
maxSessionsis optional now: deployments can set a cap for their capacity, and the configured cap still returns 503 when active or in-progress sessions reach it. The default no longer stops new clients after 100 abandoned sessions.Tests: 5 focused session manager tests and all 566 Swift tests passed locally on
bf10e4d. The session manager tests passed in Ubuntu CI. macOS, conformance, documentation, and Linux static build passed. The Ubuntu test job timed out in twoClientTestsand was cancelled at 10 minutes; a rerun is needed. AI helped write the new tests; I ran them.