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

Commit 31c1209

Browse files
authored
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 <[email protected]>
1 parent 9c4c499 commit 31c1209

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

changelog.d/12366.misc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Make `StreamToken.from_string` and `RoomStreamToken.parse` propagate cancellations instead of replacing them with `SynapseError`s.

synapse/types.py

+5
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
from unpaddedbase64 import decode_base64
4040
from zope.interface import Interface
4141

42+
from twisted.internet.defer import CancelledError
4243
from twisted.internet.interfaces import (
4344
IReactorCore,
4445
IReactorPluggableNameResolver,
@@ -540,6 +541,8 @@ async def parse(cls, store: "PurgeEventsStore", string: str) -> "RoomStreamToken
540541
stream=stream,
541542
instance_map=frozendict(instance_map),
542543
)
544+
except CancelledError:
545+
raise
543546
except Exception:
544547
pass
545548
raise SynapseError(400, "Invalid room stream token %r" % (string,))
@@ -705,6 +708,8 @@ async def from_string(cls, store: "DataStore", string: str) -> "StreamToken":
705708
return cls(
706709
await RoomStreamToken.parse(store, keys[0]), *(int(k) for k in keys[1:])
707710
)
711+
except CancelledError:
712+
raise
708713
except Exception:
709714
raise SynapseError(400, "Invalid stream token")
710715

0 commit comments

Comments
 (0)