send-to-paseo 2.4.1-beta.0 → 2.4.1-beta.1
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/package.json +1 -1
- package/server/follow-up-id.ts +18 -3
- package/shared/contracts.ts +1 -1
package/package.json
CHANGED
package/server/follow-up-id.ts
CHANGED
|
@@ -7,12 +7,27 @@ export const FOLLOW_UP_PLUGIN_IDS = ["follow-up", "follow-through"] as const;
|
|
|
7
7
|
/** Paseo's answer when no plugin runs under the id (0.15: "Plugin is not available: <id>"). */
|
|
8
8
|
const absent = (error: unknown) => /plugin (?:is )?not (?:available|installed|configured)|unknown plugin/i.test(error instanceof Error ? error.message : String(error));
|
|
9
9
|
|
|
10
|
+
/**
|
|
11
|
+
* The browser bridge polls every few seconds, and the daemon logs every absent-plugin answer at error level, so an id
|
|
12
|
+
* is never re-probed per call. The id that answered goes first next time and is only abandoned when it comes back
|
|
13
|
+
* absent (2.0 moved to a new id mid-process, or a rollback). When neither id is installed, that fact is cached for
|
|
14
|
+
* `ABSENT_TTL_MS` so a host without Follow-up isn't probed on every poll either.
|
|
15
|
+
*/
|
|
16
|
+
const ABSENT_TTL_MS = 30_000;
|
|
17
|
+
let remembered: (typeof FOLLOW_UP_PLUGIN_IDS)[number] | undefined;
|
|
18
|
+
let neitherUntil = 0;
|
|
19
|
+
let neitherError: unknown;
|
|
20
|
+
|
|
10
21
|
/** Calls `method` on whichever Follow-up id answers. Any other failure (an RPC error, a timeout) is the answer. */
|
|
11
|
-
export async function invokeFollowUp(invoke: (pluginId: string, method: string, input: unknown) => Promise<unknown>, method: string, input: unknown): Promise<unknown> {
|
|
22
|
+
export async function invokeFollowUp(invoke: (pluginId: string, method: string, input: unknown) => Promise<unknown>, method: string, input: unknown, now: () => number = Date.now): Promise<unknown> {
|
|
23
|
+
if (!remembered && now() < neitherUntil) throw neitherError;
|
|
24
|
+
const order = remembered ? [remembered, ...FOLLOW_UP_PLUGIN_IDS.filter(id => id !== remembered)] : FOLLOW_UP_PLUGIN_IDS;
|
|
12
25
|
let last: unknown;
|
|
13
|
-
for (const id of
|
|
14
|
-
try {
|
|
26
|
+
for (const id of order) {
|
|
27
|
+
try { const answer = await invoke(id, method, input); remembered = id; return answer; }
|
|
15
28
|
catch (error) { if (!absent(error)) throw error; last = error; }
|
|
16
29
|
}
|
|
30
|
+
remembered = undefined;
|
|
31
|
+
neitherError = last; neitherUntil = now() + ABSENT_TTL_MS;
|
|
17
32
|
throw last;
|
|
18
33
|
}
|
package/shared/contracts.ts
CHANGED
|
@@ -9,7 +9,7 @@ import { z } from "zod";
|
|
|
9
9
|
|
|
10
10
|
/** Advertised in `GET /v1/ping`. Keep in step with `package.json`. */
|
|
11
11
|
export const PLUGIN_NAME = "send-to-paseo";
|
|
12
|
-
export const PLUGIN_VERSION = "2.4.1-beta.
|
|
12
|
+
export const PLUGIN_VERSION = "2.4.1-beta.1";
|
|
13
13
|
/** Bumped only for an incompatible bridge API; the paths stay `/v1`. */
|
|
14
14
|
export const CONTRACT_VERSION = 1;
|
|
15
15
|
|