-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Add @cancellable
decorator, for use on endpoint methods that can be cancelled when clients disconnect
#12583
Commits on Apr 28, 2022
-
Add
@cancellable
decorator, for use on request handlersSigned-off-by: Sean Quah <seanq@element.io>
Sean Quah committedApr 28, 2022 Configuration menu - View commit details
-
Copy full SHA for 2780bed - Browse repository at this point
Copy the full SHA 2780bedView commit details -
Improve logging for cancelled requests
Don't log stack traces for cancelled requests and use a custom HTTP status code of 499. Signed-off-by: Sean Quah <seanq@element.io>
Sean Quah committedApr 28, 2022 Configuration menu - View commit details
-
Copy full SHA for 1ce7dbf - Browse repository at this point
Copy the full SHA 1ce7dbfView commit details -
Add ability to cancel disconnected requests to
SynapseRequest
Signed-off-by: Sean Quah <seanq@element.io>
Sean Quah committedApr 28, 2022 Configuration menu - View commit details
-
Copy full SHA for 0dc4178 - Browse repository at this point
Copy the full SHA 0dc4178View commit details -
Capture the
Deferred
for request cancellation in_AsyncResource
All async request processing goes through `_AsyncResource`, so this is the only place where a `Deferred` needs to be captured for cancellation. Unfortunately, the same isn't true for determining whether a request can be cancelled. Each of `RestServlet`, `BaseFederationServlet`, `DirectServe{Html,Json}Resource` and `ReplicationEndpoint` have different wrappers around the method doing the request handling and they all need to be handled separately. Signed-off-by: Sean Quah <seanq@element.io>
Sean Quah committedApr 28, 2022 Configuration menu - View commit details
-
Copy full SHA for 5a9991c - Browse repository at this point
Copy the full SHA 5a9991cView commit details -
Respect the
@cancellable
flag forDirectServe{Html,Json}Resource
s`DirectServeHtmlResource` and `DirectServeJsonResource` both inherit from `_AsyncResource`. These classes expect to be subclassed with `_async_render_*` methods. This commit has no effect on `JsonResource`, despite inheriting from `_AsyncResource`. `JsonResource` has its own `_async_render` override which will need to be updated separately. Signed-off-by: Sean Quah <seanq@element.io>
Sean Quah committedApr 28, 2022 Configuration menu - View commit details
-
Copy full SHA for 46cdb4b - Browse repository at this point
Copy the full SHA 46cdb4bView commit details -
Respect the
@cancellable
flag forRestServlet
s and `BaseFederatio……nServlet`s Both `RestServlet`s and `BaseFederationServlet`s register their handlers with `HttpServer.register_paths` / `JsonResource.register_paths`. Update `JsonResource` to respect the `@cancellable` flag on handlers registered in this way. Although `ReplicationEndpoint` also registers itself using `register_paths`, it does not pass the handler method that would have the `@cancellable` flag directly, and so needs separate handling. Signed-off-by: Sean Quah <seanq@element.io>
Sean Quah committedApr 28, 2022 Configuration menu - View commit details
-
Copy full SHA for 2326bbf - Browse repository at this point
Copy the full SHA 2326bbfView commit details -
Complain if a federation endpoint has the
@cancellable
flag`BaseFederationServlet` wraps its endpoints in a bunch of async code that has not been vetted for compatibility with cancellation. Fail CI if a `@cancellable` flag is applied to a federation endpoint. Signed-off-by: Sean Quah <seanq@element.io>
Sean Quah committedApr 28, 2022 Configuration menu - View commit details
-
Copy full SHA for c3eb1e3 - Browse repository at this point
Copy the full SHA c3eb1e3View commit details -
Respect the
@cancellable
flag forReplicationEndpoint
sWhile `ReplicationEndpoint`s register themselves via `JsonResource`, they pass a method that calls the handler, instead of the handler itself, to `register_paths`. As a result, `JsonResource` will not correctly pick up the `@cancellable` flag and we have to apply it ourselves. Signed-off-by: Sean Quah <seanq@element.io>
Sean Quah committedApr 28, 2022 Configuration menu - View commit details
-
Copy full SHA for 62d3b91 - Browse repository at this point
Copy the full SHA 62d3b91View commit details -
Expose the
SynapseRequest
fromFakeChannel
for testing disconnectionIn order to simulate a client disconnection in tests, we would like to call `Request.connectionLost`. Make the `Request` accessible from the `FakeChannel` returned by `make_request`. Signed-off-by: Sean Quah <seanq@element.io>
Sean Quah committedApr 28, 2022 Configuration menu - View commit details
-
Copy full SHA for 3d89472 - Browse repository at this point
Copy the full SHA 3d89472View commit details -
Add helper class for testing request cancellation
Signed-off-by: Sean Quah <seanq@element.io>
Sean Quah committedApr 28, 2022 Configuration menu - View commit details
-
Copy full SHA for 2bbad29 - Browse repository at this point
Copy the full SHA 2bbad29View commit details -
Test the
@cancellable
flag onRestServlet
methodsSigned-off-by: Sean Quah <seanq@element.io>
Sean Quah committedApr 28, 2022 Configuration menu - View commit details
-
Copy full SHA for 6720b87 - Browse repository at this point
Copy the full SHA 6720b87View commit details -
Test the
@cancellable
flag onDirectServe{Html,Json}Resource
methodsSigned-off-by: Sean Quah <seanq@element.io>
Sean Quah committedApr 28, 2022 Configuration menu - View commit details
-
Copy full SHA for 92b7b17 - Browse repository at this point
Copy the full SHA 92b7b17View commit details -
Test the
@cancellable
flag onReplicationEndpoint._handle_request
Signed-off-by: Sean Quah <seanq@element.io>
Sean Quah committedApr 28, 2022 Configuration menu - View commit details
-
Copy full SHA for d3f75f3 - Browse repository at this point
Copy the full SHA d3f75f3View commit details -
Fix
make_signed_federation_request
turning empty dicts intob""
Signed-off-by: Sean Quah <seanq@element.io>
Sean Quah committedApr 28, 2022 Configuration menu - View commit details
-
Copy full SHA for 3544cfd - Browse repository at this point
Copy the full SHA 3544cfdView commit details -
Test the
@cancellable
flag onBaseFederationServlet
methodsSigned-off-by: Sean Quah <seanq@element.io>
Sean Quah committedApr 28, 2022 Configuration menu - View commit details
-
Copy full SHA for 89cb0f1 - Browse repository at this point
Copy the full SHA 89cb0f1View commit details -
Disable tests for the
@cancellable
flag onBaseFederationServlet
……methods Signed-off-by: Sean Quah <seanq@element.io>
Sean Quah committedApr 28, 2022 Configuration menu - View commit details
-
Copy full SHA for 342a502 - Browse repository at this point
Copy the full SHA 342a502View commit details -
Configuration menu - View commit details
-
Copy full SHA for a89fc72 - Browse repository at this point
Copy the full SHA a89fc72View commit details
Commits on May 6, 2022
-
Don't trash the logging context when cancelling request processing
Signed-off-by: Sean Quah <seanq@element.io>
Sean Quah committedMay 6, 2022 Configuration menu - View commit details
-
Copy full SHA for 3f8a59f - Browse repository at this point
Copy the full SHA 3f8a59fView commit details -
Rename to
EndpointCancellationTestCase
to `EndpointCancellationTest……HelperMixin` Signed-off-by: Sean Quah <seanq@element.io>
Sean Quah committedMay 6, 2022 Configuration menu - View commit details
-
Copy full SHA for 08acc0c - Browse repository at this point
Copy the full SHA 08acc0cView commit details -
Add missing docstring for
expected_body
parameterSigned-off-by: Sean Quah <seanq@element.io>
Sean Quah committedMay 6, 2022 Configuration menu - View commit details
-
Copy full SHA for 4976ae5 - Browse repository at this point
Copy the full SHA 4976ae5View commit details -
Improve assertion message when
await_result=False
is forgottenSigned-off-by: Sean Quah <seanq@element.io>
Sean Quah committedMay 6, 2022 Configuration menu - View commit details
-
Copy full SHA for 4e644ea - Browse repository at this point
Copy the full SHA 4e644eaView commit details