rechrome 1.23.1 → 1.23.3

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.
@@ -1,6 +1,19 @@
1
1
  import { c as clientExports, j as jsxRuntimeExports, r as reactExports, A as AuthTokenSection, T as TabItem, B as Button, g as getOrCreateAuthToken } from "./authToken.js";
2
2
  const SUPPORTED_PROTOCOL_VERSION = 2;
3
3
  const BACKGROUND_RESPONSE_TIMEOUT_MS = 1e4;
4
+ const SELF_RELOAD_GUARD_KEY = "connect-self-reload-at";
5
+ const SELF_RELOAD_MIN_INTERVAL_MS = 6e4;
6
+ function attemptExtensionSelfReload() {
7
+ if (new URLSearchParams(window.location.search).get("selfReload") !== "1")
8
+ return false;
9
+ const last = Number(localStorage.getItem(SELF_RELOAD_GUARD_KEY) || 0);
10
+ const now = Date.now();
11
+ if (now - last < SELF_RELOAD_MIN_INTERVAL_MS)
12
+ return false;
13
+ localStorage.setItem(SELF_RELOAD_GUARD_KEY, String(now));
14
+ chrome.runtime.reload();
15
+ return true;
16
+ }
4
17
  async function sendMessageWithTimeout(message, simulateHang = false) {
5
18
  let timer;
6
19
  try {
@@ -78,7 +91,8 @@ const ConnectApp = () => {
78
91
  );
79
92
  } catch (error) {
80
93
  if (hasAutomationToken && !recoveryAttempt) {
81
- setError("Extension service worker is not responding. Retrying once…");
94
+ const reloading = attemptExtensionSelfReload();
95
+ setError(reloading ? "Extension service worker is not responding. Reloading extension and retrying…" : "Extension service worker is not responding. Retrying once…");
82
96
  return;
83
97
  }
84
98
  setError(`Extension service worker did not recover: ${error.message}`);
@@ -137,7 +151,8 @@ const ConnectApp = () => {
137
151
  const recoveryAttempt = new URLSearchParams(window.location.search).get("recoveryAttempt") === "1";
138
152
  const hasAutomationToken = !!new URLSearchParams(window.location.search).get("token");
139
153
  if (hasAutomationToken && !recoveryAttempt) {
140
- setError("Extension service worker stopped during connection. Retrying once…");
154
+ const reloading = attemptExtensionSelfReload();
155
+ setError(reloading ? "Extension service worker stopped during connection. Reloading extension and retrying…" : "Extension service worker stopped during connection. Retrying once…");
141
156
  return;
142
157
  }
143
158
  setStatus({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rechrome",
3
- "version": "1.23.1",
3
+ "version": "1.23.3",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/snomiao/rechrome.git"
package/rech.js CHANGED
@@ -1593,8 +1593,12 @@ async function status(): Promise<void> {
1593
1593
  const bind = pingBody?.bind;
1594
1594
  const listenAddr = bind ? `${bind}:${port}` : `${host}:${port}`;
1595
1595
  console.log(`serve: ${ping ? `running ${protocol}://${listenAddr}` : "not running"}`);
1596
+ // daemonManager().id — there is no PM_BIN constant. Referencing one threw a
1597
+ // ReferenceError that took down the whole of `rech status`, so the one command
1598
+ // that reports "the relay is wedged" died exactly when the relay was wedged,
1599
+ // printing a stack trace instead of the restart hint.
1596
1600
  if (pingBody?.degraded)
1597
- console.log(`relay: ⚠ degraded (${pingBody.consecutiveTimeouts} consecutive command timeouts) — if it persists, the daemon self-restarts; force it now with \`${PM_BIN} restart ${PM_PROCESS_NAME}\``);
1601
+ console.log(`relay: ⚠ degraded (${pingBody.consecutiveTimeouts} consecutive command timeouts) — if it persists, the daemon self-restarts; force it now with \`${daemonManager().id} restart ${PM_PROCESS_NAME}\``);
1598
1602
  const pmOut = await pmList();
1599
1603
  const daemonRegistered = pmOut.includes(PM_PROCESS_NAME);
1600
1604
  console.log(`daemon: ${daemonRegistered ? `${daemonManager().id} (${PM_PROCESS_NAME})` : "not installed"}`);
package/rech.ts CHANGED
@@ -1593,8 +1593,12 @@ async function status(): Promise<void> {
1593
1593
  const bind = pingBody?.bind;
1594
1594
  const listenAddr = bind ? `${bind}:${port}` : `${host}:${port}`;
1595
1595
  console.log(`serve: ${ping ? `running ${protocol}://${listenAddr}` : "not running"}`);
1596
+ // daemonManager().id — there is no PM_BIN constant. Referencing one threw a
1597
+ // ReferenceError that took down the whole of `rech status`, so the one command
1598
+ // that reports "the relay is wedged" died exactly when the relay was wedged,
1599
+ // printing a stack trace instead of the restart hint.
1596
1600
  if (pingBody?.degraded)
1597
- console.log(`relay: ⚠ degraded (${pingBody.consecutiveTimeouts} consecutive command timeouts) — if it persists, the daemon self-restarts; force it now with \`${PM_BIN} restart ${PM_PROCESS_NAME}\``);
1601
+ console.log(`relay: ⚠ degraded (${pingBody.consecutiveTimeouts} consecutive command timeouts) — if it persists, the daemon self-restarts; force it now with \`${daemonManager().id} restart ${PM_PROCESS_NAME}\``);
1598
1602
  const pmOut = await pmList();
1599
1603
  const daemonRegistered = pmOut.includes(PM_PROCESS_NAME);
1600
1604
  console.log(`daemon: ${daemonRegistered ? `${daemonManager().id} (${PM_PROCESS_NAME})` : "not installed"}`);