Skip to content

UnboundLocalError: now_token in /sync for appservice bots using MSC3202 (regression in v1.150.0) #19618

@Just-Insane

Description

@Just-Insane

Description

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

Anything else that would be useful to know?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions