Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Make StreamToken and RoomStreamToken methods propagate cancellations #12366

Merged
merged 1 commit into from
Apr 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/12366.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Make `StreamToken.from_string` and `RoomStreamToken.parse` propagate cancellations instead of replacing them with `SynapseError`s.
5 changes: 5 additions & 0 deletions synapse/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
from unpaddedbase64 import decode_base64
from zope.interface import Interface

from twisted.internet.defer import CancelledError
from twisted.internet.interfaces import (
IReactorCore,
IReactorPluggableNameResolver,
Expand Down Expand Up @@ -516,6 +517,8 @@ async def parse(cls, store: "PurgeEventsStore", string: str) -> "RoomStreamToken
stream=stream,
instance_map=frozendict(instance_map),
)
except CancelledError:
raise
except Exception:
pass
raise SynapseError(400, "Invalid room stream token %r" % (string,))
Expand Down Expand Up @@ -631,6 +634,8 @@ async def from_string(cls, store: "DataStore", string: str) -> "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")

Expand Down