diff options
author | Sean Quah <8349537+squahtx@users.noreply.github.com> | 2022-04-05 16:56:52 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-05 16:56:52 +0100 |
commit | 31c1209c50c08929fe7c6f2f7531fb9def422c94 (patch) | |
tree | 99406c7485bfc962f017fc1776013e97030af593 /synapse | |
parent | Update docstrings for `ReadWriteLock` tests (#12354) (diff) | |
download | synapse-31c1209c50c08929fe7c6f2f7531fb9def422c94.tar.xz |
Make `StreamToken` and `RoomStreamToken` methods propagate cancellations (#12366)
`StreamToken.from_string` and `RoomStreamToken.parse` are both async methods that could be cancelled. These methods must not replace `CancelledError`s with `SynapseError`s. Signed-off-by: Sean Quah <seanq@element.io>
Diffstat (limited to 'synapse')
-rw-r--r-- | synapse/types.py | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/synapse/types.py b/synapse/types.py index 6bbefb6faa..9ac688b23b 100644 --- a/synapse/types.py +++ b/synapse/types.py @@ -39,6 +39,7 @@ from typing_extensions import TypedDict from unpaddedbase64 import decode_base64 from zope.interface import Interface +from twisted.internet.defer import CancelledError from twisted.internet.interfaces import ( IReactorCore, IReactorPluggableNameResolver, @@ -540,6 +541,8 @@ class RoomStreamToken: stream=stream, instance_map=frozendict(instance_map), ) + except CancelledError: + raise except Exception: pass raise SynapseError(400, "Invalid room stream token %r" % (string,)) @@ -705,6 +708,8 @@ class StreamToken: return cls( await RoomStreamToken.parse(store, keys[0]), *(int(k) for k in keys[1:]) ) + except CancelledError: + raise except Exception: raise SynapseError(400, "Invalid stream token") |