feat(core): improve reconnect handling (#15458)

#### PR Dependency Tree


* **PR #15458** 👈

This tree was auto-generated by
[Charcoal](https://github.com/danerwilliams/charcoal)

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **Bug Fixes**
* Improved realtime connection recovery with progressively longer retry
delays, capped to prevent excessive waiting.
* Connection retries now reset after successful reconnection and stop
cleanly when no longer needed.
* Reduced false error alerts by confirming repeated failures before
notifying users.
* Added cancellation handling when connection context changes or the
service is closed.

* **User Experience**
* Realtime connection alerts now identify authentication, network,
server, and timeout issues with localized messages.
* Active alerts are automatically dismissed when the connection
recovers.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
DarkSky
2026-08-10 21:44:24 +08:00
committed by GitHub
parent 25de261c9e
commit 749c83cd8e
8 changed files with 142 additions and 24 deletions
+14 -2
View File
@@ -9681,9 +9681,21 @@ export function useAFFiNEI18N(): {
*/
["com.affine.realtime.connection-error.title"](): string;
/**
* `Check that your server proxy forwards /socket.io over WebSocket or HTTP polling.`
* `The real-time connection could not authenticate your session. Sign in again if the problem continues.`
*/
["com.affine.realtime.connection-error.message"](): string;
["com.affine.realtime.connection-error.authentication"](): string;
/**
* `The server cannot be reached. Check your network connection and server proxy.`
*/
["com.affine.realtime.connection-error.network"](): string;
/**
* `The server rejected the real-time request. Try again later.`
*/
["com.affine.realtime.connection-error.server"](): string;
/**
* `The server did not respond in time. AFFiNE will keep trying to reconnect.`
*/
["com.affine.realtime.connection-error.timeout"](): string;
/**
* `An internal error occurred.`
*/
@@ -2307,7 +2307,6 @@
"com.affine.settings.devices.sign-out-failed": "Gerät konnte nicht abgemeldet werden",
"com.affine.settings.devices.sign-out-all-failed": "Geräte konnten nicht abgemeldet werden",
"com.affine.realtime.connection-error.title": "Echtzeitverbindung fehlgeschlagen",
"com.affine.realtime.connection-error.message": "Stelle sicher, dass dein Server-Proxy /socket.io über WebSocket oder HTTP-Polling weiterleitet.",
"error.INTERNAL_SERVER_ERROR": "Es ist ein interner Fehler aufgetreten.",
"error.NETWORK_ERROR": "Netzwerkfehler.",
"error.TOO_MANY_REQUEST": "Zu viele Anfragen.",
+4 -1
View File
@@ -2410,7 +2410,10 @@
"com.affine.settings.devices.sign-out-failed": "Failed to sign out device",
"com.affine.settings.devices.sign-out-all-failed": "Failed to sign out devices",
"com.affine.realtime.connection-error.title": "Real-time connection failed",
"com.affine.realtime.connection-error.message": "Check that your server proxy forwards /socket.io over WebSocket or HTTP polling.",
"com.affine.realtime.connection-error.authentication": "The real-time connection could not authenticate your session. Sign in again if the problem continues.",
"com.affine.realtime.connection-error.network": "The server cannot be reached. Check your network connection and server proxy.",
"com.affine.realtime.connection-error.server": "The server rejected the real-time request. Try again later.",
"com.affine.realtime.connection-error.timeout": "The server did not respond in time. AFFiNE will keep trying to reconnect.",
"error.INTERNAL_SERVER_ERROR": "An internal error occurred.",
"error.NETWORK_ERROR": "Network error.",
"error.TOO_MANY_REQUEST": "Too many requests.",
@@ -2307,7 +2307,6 @@
"error.INTERNAL_SERVER_ERROR": "发生内部错误。",
"error.NETWORK_ERROR": "网络错误。",
"com.affine.realtime.connection-error.title": "实时同步连接失败",
"com.affine.realtime.connection-error.message": "请检查服务器反向代理是否通过 WebSocket 或 HTTP polling 正确转发 /socket.io。",
"error.TOO_MANY_REQUEST": "请求过多。",
"error.SSRF_BLOCKED_ERROR": "无效的 URL",
"error.RESPONSE_TOO_LARGE_ERROR": "响应过大({{receivedBytes}} 字节),限制为 {{limitBytes}} 字节",