mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2024-10-01 11:49:51 -04:00
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>
This commit is contained in:
parent
9c4c49991d
commit
31c1209c50
1
changelog.d/12366.misc
Normal file
1
changelog.d/12366.misc
Normal file
@ -0,0 +1 @@
|
||||
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
|
||||
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")
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user