Skip to content
Snippets Groups Projects
Unverified Commit 31c1209c authored by Sean Quah's avatar Sean Quah Committed by GitHub
Browse files

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: default avatarSean Quah <seanq@element.io>
parent 9c4c4999
No related branches found
No related tags found
No related merge requests found
Make `StreamToken.from_string` and `RoomStreamToken.parse` propagate cancellations instead of replacing them with `SynapseError`s.
...@@ -39,6 +39,7 @@ from typing_extensions import TypedDict ...@@ -39,6 +39,7 @@ from typing_extensions import TypedDict
from unpaddedbase64 import decode_base64 from unpaddedbase64 import decode_base64
from zope.interface import Interface from zope.interface import Interface
from twisted.internet.defer import CancelledError
from twisted.internet.interfaces import ( from twisted.internet.interfaces import (
IReactorCore, IReactorCore,
IReactorPluggableNameResolver, IReactorPluggableNameResolver,
...@@ -540,6 +541,8 @@ class RoomStreamToken: ...@@ -540,6 +541,8 @@ class RoomStreamToken:
stream=stream, stream=stream,
instance_map=frozendict(instance_map), instance_map=frozendict(instance_map),
) )
except CancelledError:
raise
except Exception: except Exception:
pass pass
raise SynapseError(400, "Invalid room stream token %r" % (string,)) raise SynapseError(400, "Invalid room stream token %r" % (string,))
...@@ -705,6 +708,8 @@ class StreamToken: ...@@ -705,6 +708,8 @@ class StreamToken:
return cls( return cls(
await RoomStreamToken.parse(store, keys[0]), *(int(k) for k in keys[1:]) await RoomStreamToken.parse(store, keys[0]), *(int(k) for k in keys[1:])
) )
except CancelledError:
raise
except Exception: except Exception:
raise SynapseError(400, "Invalid stream token") raise SynapseError(400, "Invalid stream token")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment