summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--changelog.d/12366.misc1
-rw-r--r--synapse/types.py5
2 files changed, 6 insertions, 0 deletions
diff --git a/changelog.d/12366.misc b/changelog.d/12366.misc
new file mode 100644
index 0000000000..33d8e6c712
--- /dev/null
+++ b/changelog.d/12366.misc
@@ -0,0 +1 @@
+Make `StreamToken.from_string` and `RoomStreamToken.parse` propagate cancellations instead of replacing them with `SynapseError`s.
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")