bb-browser 0.5.1 → 0.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +20 -0
- package/dist/cli.js.map +1 -1
- package/extension/background.js +1 -10
- package/extension/background.js.map +1 -1
- package/extension/dist/background.js +1 -10
- package/extension/dist/background.js.map +1 -1
- package/extension/dist/manifest.json +1 -1
- package/extension/manifest.json +1 -1
- package/package.json +1 -1
package/extension/background.js
CHANGED
|
@@ -2,7 +2,6 @@ const DEFAULT_DAEMON_PORT = 19824;
|
|
|
2
2
|
const DEFAULT_DAEMON_HOST = "localhost";
|
|
3
3
|
const DEFAULT_DAEMON_BASE_URL = `http://${DEFAULT_DAEMON_HOST}:${DEFAULT_DAEMON_PORT}`;
|
|
4
4
|
const SSE_RECONNECT_DELAY = 3e3;
|
|
5
|
-
const SSE_MAX_RECONNECT_ATTEMPTS = 5;
|
|
6
5
|
const STORAGE_KEY = "upstreamUrl";
|
|
7
6
|
async function getUpstreamUrl() {
|
|
8
7
|
try {
|
|
@@ -60,7 +59,6 @@ class SSEClient {
|
|
|
60
59
|
console.log("[SSEClient] Connection aborted");
|
|
61
60
|
return;
|
|
62
61
|
}
|
|
63
|
-
console.error("[SSEClient] Connection error:", error);
|
|
64
62
|
this.isConnectedFlag = false;
|
|
65
63
|
this.reconnect();
|
|
66
64
|
}
|
|
@@ -147,15 +145,8 @@ class SSEClient {
|
|
|
147
145
|
* 指数退避重连
|
|
148
146
|
*/
|
|
149
147
|
reconnect() {
|
|
150
|
-
if (this.reconnectAttempts >= SSE_MAX_RECONNECT_ATTEMPTS) {
|
|
151
|
-
console.error("[SSEClient] Max reconnection attempts reached");
|
|
152
|
-
return;
|
|
153
|
-
}
|
|
154
148
|
this.reconnectAttempts++;
|
|
155
|
-
const delay = SSE_RECONNECT_DELAY * Math.pow(2, this.reconnectAttempts - 1);
|
|
156
|
-
console.log(
|
|
157
|
-
`[SSEClient] Reconnecting in ${delay}ms (attempt ${this.reconnectAttempts}/${SSE_MAX_RECONNECT_ATTEMPTS})`
|
|
158
|
-
);
|
|
149
|
+
const delay = Math.min(SSE_RECONNECT_DELAY * Math.pow(2, this.reconnectAttempts - 1), 6e4);
|
|
159
150
|
setTimeout(() => {
|
|
160
151
|
this.disconnect();
|
|
161
152
|
this.connect();
|