diff --git a/mautrix_telegram/config.py b/mautrix_telegram/config.py index 5c46c5df..d429cdbc 100644 --- a/mautrix_telegram/config.py +++ b/mautrix_telegram/config.py @@ -194,6 +194,7 @@ class Config(BaseBridgeConfig): copy("bridge.backfill.forward_limits.sync.normal_group") copy("bridge.backfill.forward_limits.sync.supergroup") copy("bridge.backfill.forward_limits.sync.channel") + copy("bridge.backfill.forward_timeout") copy("bridge.backfill.incremental.messages_per_batch") copy("bridge.backfill.incremental.post_batch_delay") copy("bridge.backfill.incremental.max_batches.user") diff --git a/mautrix_telegram/example-config.yaml b/mautrix_telegram/example-config.yaml index 1e2ce125..4cb051bf 100644 --- a/mautrix_telegram/example-config.yaml +++ b/mautrix_telegram/example-config.yaml @@ -420,6 +420,8 @@ bridge: normal_group: 100 supergroup: 100 channel: 100 + # Timeout for forward backfills in seconds. If you have a high limit, you'll have to increase this too. + forward_timeout: 900 # Settings for incremental backfill of history. These only apply when using MSC2716. incremental: diff --git a/mautrix_telegram/portal.py b/mautrix_telegram/portal.py index 7ebb639b..cc40cc7a 100644 --- a/mautrix_telegram/portal.py +++ b/mautrix_telegram/portal.py @@ -2885,13 +2885,15 @@ class Portal(DBPortal, BasePortal): ) if limit == 0: return "Limit is zero, not backfilling" + timeout = self.config["bridge.backfill.forward_timeout"] with self.backfill_lock: - output = await asyncio.wait_for( - self.backfill( - source, client, forward=True, forward_limit=limit, last_tgid=last_tgid - ), - timeout=15 * 60, + task = self.backfill( + source, client, forward=True, forward_limit=limit, last_tgid=last_tgid ) + if timeout > 0: + output = await asyncio.wait_for(task, timeout=timeout) + else: + output = await task self.log.debug(f"Forward backfill complete, status: {output}") return output