You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
UnboundLocalError: now_token in /sync for appservice bots using MSC3202 (regression in v1.150.0) #19618
Synapse v1.150.0 causes all /sync requests from appservice bridge bots to fail with HTTP 500 when msc4190_enabled: true. Every bridge bot's sync crashes every ~10 seconds, breaking all E2EE message delivery to/from bridges.
Steps to reproduce
Steps to reproduce:
Enable MSC4190 in homeserver.yaml: experimental_features: { msc4190_enabled: true }
Start any mautrix bridge (discord, signal, whatsapp, etc.) with E2EE enabled
Bridge bot calls GET /_matrix/client/v3/sync?org.matrix.msc3202.device_id=<device_id>&user_id=@bot:example.com
Synapse returns HTTP 500 on every sync request from the bot
What happened vs expected:
Expected: Bridge bots sync successfully and can participate in E2EE rooms.
Actual: Every sync request returns HTTP 500 with UnboundLocalError: cannot access local variable 'now_token'. All bridges stop receiving/decrypting messages.
Workaround: Setting msc4354_enabled: false fully resolves the issue, indicating the regression was introduced by #19487 (MSC4354 sticky events in legacy /sync).
Homeserver
Self-hosted (matrix.cloudhub.social)
Synapse Version
1.150.0
Installation Method
Docker (matrixdotorg/synapse)
Database
PostgreSQL: single server, no recent restore
Workers
Single process
Platform
Docker container, Linux (Debian)
Configuration
experimental_features:
msc4354_enabled: true # sticky events — disabling this is the workaround
Relevant log output
UnboundLocalError: cannot access local variable 'now_token' where it is not associated with a value
File ".../synapse/http/server.py", line 335, in _async_render_wrapper
File ".../synapse/http/server.py", line 576, in _async_render
File ".../synapse/rest/client/sync.py", line 271, in on_GET
File ".../synapse/handlers/sync.py", line 365, in wait_for_sync_for_user
File ".../synapse/util/caches/response_cache.py", line 402, in wrap
File ".../synapse/util/caches/response_cache.py", line 343, in cb
UnboundLocalError: cannot access local variable 'now_token' where it is not associated with a value
This is not related to the bug, but note that there's no experimental_features key called msc4190_enabled and never has been, that field is a no-op. Also, the device_id query param was moved to MSC4326. MSC3202 is the solution for replacing /sync, so if you're using /sync, you're not using MSC3202. Both MSC4190 and MSC4326 are already in the spec (but MSC3202 is not)
Activity
tulir commentedon Mar 27, 2026
This is not related to the bug, but note that there's no
experimental_featureskey calledmsc4190_enabledand never has been, that field is a no-op. Also, the device_id query param was moved to MSC4326. MSC3202 is the solution for replacing /sync, so if you're using /sync, you're not using MSC3202. Both MSC4190 and MSC4326 are already in the spec (but MSC3202 is not)Just-Insane commentedon Mar 27, 2026
Ah, yup, my bad. I am using the Matrix-Docker-Ansible-Deploy playbook with the following config:
With
matrix_synapse_experimental_features_msc4354_enabled: true, I get the error from this issue.MadLittleMods commentedon Apr 2, 2026
Bug is here and introduced in #19487 as you suspected:
synapse/synapse/handlers/sync.py
Lines 2223 to 2225 in 62f23fe
It should be using
sync_result_builder.now_token.It sucks that we don't have any linters that yell about the
Unboundvalue. I can see the typing in VSCode.cc @reivilibre
MadLittleMods commentedon May 16, 2026
This is fixed by #19787
Fix `/sync` failing when MSC4354 Sticky Events are enabled and the sy…
Fix `/sync` failing when MSC4354 Sticky Events are enabled and the sy…