@gmickel/gno 2.9.0 → 2.9.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/README.md +1 -1
- package/browser-extension/artifacts/{gno-browser-clipper-v2.9.0.zip → gno-browser-clipper-v2.9.1.zip} +0 -0
- package/browser-extension/artifacts/gno-browser-clipper-v2.9.1.zip.sha256 +1 -0
- package/browser-extension/dist/manifest.json +1 -1
- package/package.json +1 -1
- package/src/serve/watch-reconciliation-shared.ts +12 -1
- package/src/serve/watch-reconciliation.ts +2 -0
- package/src/serve/watch-service-events.ts +43 -9
- package/src/serve/watch-service-hosts.ts +12 -2
- package/src/serve/watch-service-lifecycle.ts +8 -0
- package/src/serve/watch-service-run-flush.ts +13 -2
- package/src/serve/watch-service.ts +10 -1
- package/browser-extension/artifacts/gno-browser-clipper-v2.9.0.zip.sha256 +0 -1
package/README.md
CHANGED
|
@@ -139,7 +139,7 @@ See the [guide](docs/COMPILED-CONTEXT.md).
|
|
|
139
139
|
|
|
140
140
|
<!-- public-truth:current-version -->
|
|
141
141
|
|
|
142
|
-
> Current source version: **v2.9.
|
|
142
|
+
> Current source version: **v2.9.1**. See [CHANGELOG.md](./CHANGELOG.md).
|
|
143
143
|
|
|
144
144
|
<!-- /public-truth -->
|
|
145
145
|
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
f58e51eea9d0b35a61ef55574882c4be8002ed2fdc29966a3cd1bd7c84350e3c gno-browser-clipper-v2.9.1.zip
|
package/package.json
CHANGED
|
@@ -42,9 +42,20 @@ export const WATCHER_MAX_DIRTY_HINTS = 4_096;
|
|
|
42
42
|
/** Cap on application-write suppression history entries. */
|
|
43
43
|
export const WATCHER_MAX_SUPPRESSION_ENTRIES = 4_096;
|
|
44
44
|
|
|
45
|
-
/**
|
|
45
|
+
/** Retry delay after the first failed classification/sync of a collection. */
|
|
46
46
|
export const WATCHER_RETRY_BACKOFF_MS = 500;
|
|
47
47
|
|
|
48
|
+
/** Ceiling for the retry delay while a collection keeps failing. */
|
|
49
|
+
export const WATCHER_MAX_RETRY_BACKOFF_MS = 5 * 60_000;
|
|
50
|
+
|
|
51
|
+
/** Delay before the retry that follows `failures` consecutive failed flushes. */
|
|
52
|
+
export function watcherRetryDelayMs(failures: number): number {
|
|
53
|
+
return Math.min(
|
|
54
|
+
WATCHER_RETRY_BACKOFF_MS * 2 ** Math.max(0, failures - 1),
|
|
55
|
+
WATCHER_MAX_RETRY_BACKOFF_MS
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
|
|
48
59
|
/** Retry delay while another writer holds the shared writer lease. */
|
|
49
60
|
export const WATCHER_LEASE_RETRY_MS = 5_000;
|
|
50
61
|
|
|
@@ -28,6 +28,7 @@ export {
|
|
|
28
28
|
WATCHER_MAX_DIRTY_HINTS,
|
|
29
29
|
WATCHER_MAX_EXACT_PATHS,
|
|
30
30
|
WATCHER_MAX_FLUSH_DELAY_MS,
|
|
31
|
+
WATCHER_MAX_RETRY_BACKOFF_MS,
|
|
31
32
|
WATCHER_MAX_SUPPRESSION_ENTRIES,
|
|
32
33
|
WATCHER_RETRY_BACKOFF_MS,
|
|
33
34
|
addToCappedSet,
|
|
@@ -39,6 +40,7 @@ export {
|
|
|
39
40
|
mergeSyncPathBatch,
|
|
40
41
|
pruneSuppressionMap,
|
|
41
42
|
successfulChangedPaths,
|
|
43
|
+
watcherRetryDelayMs,
|
|
42
44
|
widenVanishedExactPaths,
|
|
43
45
|
type ClassificationResult,
|
|
44
46
|
type ExactPathKind,
|
|
@@ -12,8 +12,8 @@ import type { Collection } from "../config/types";
|
|
|
12
12
|
import {
|
|
13
13
|
WATCHER_FLUSH_DEBOUNCE_MS,
|
|
14
14
|
WATCHER_MAX_FLUSH_DELAY_MS,
|
|
15
|
-
WATCHER_RETRY_BACKOFF_MS,
|
|
16
15
|
classifyWatcherFilename,
|
|
16
|
+
watcherRetryDelayMs,
|
|
17
17
|
} from "./watch-reconciliation";
|
|
18
18
|
import {
|
|
19
19
|
applyPendingForceFlags,
|
|
@@ -25,6 +25,12 @@ import {
|
|
|
25
25
|
type PendingForceFlags,
|
|
26
26
|
} from "./watch-service-state";
|
|
27
27
|
|
|
28
|
+
/**
|
|
29
|
+
* Why an explicit retry timer is armed: "backoff" after a failed flush, "fixed"
|
|
30
|
+
* for an explicit delay such as writer-lease contention (R3: stays at 5 s).
|
|
31
|
+
*/
|
|
32
|
+
export type WatcherRetryKind = "backoff" | "fixed";
|
|
33
|
+
|
|
28
34
|
export interface WatchEventHost {
|
|
29
35
|
disposed: () => boolean;
|
|
30
36
|
findCollection: (collectionName: string) => Collection | undefined;
|
|
@@ -45,8 +51,12 @@ export interface WatchQueueHost {
|
|
|
45
51
|
pendingByCollection: Map<string, CollectionPending>;
|
|
46
52
|
flushDeadlineAt: Map<string, number>;
|
|
47
53
|
timers: Map<string, ReturnType<typeof setTimeout>>;
|
|
48
|
-
/** Collections with an explicit retry timer; finally must not bypass. */
|
|
49
|
-
retryScheduled:
|
|
54
|
+
/** Collections with an explicit retry timer, by kind; finally must not bypass. */
|
|
55
|
+
retryScheduled: Map<string, WatcherRetryKind>;
|
|
56
|
+
/** Consecutive failed flushes per collection; cleared by a successful flush. */
|
|
57
|
+
retryFailures: Map<string, number>;
|
|
58
|
+
/** Collections with watcher events queued since their last flush took its work. */
|
|
59
|
+
freshEvents: Set<string>;
|
|
50
60
|
snapshotReady: Map<string, boolean>;
|
|
51
61
|
inFlightSyncs: Set<Promise<void>>;
|
|
52
62
|
runFlush: (collectionName: string) => Promise<void>;
|
|
@@ -105,6 +115,7 @@ export function enqueueExactPath(
|
|
|
105
115
|
collectionName,
|
|
106
116
|
queueExactPath(pending, relPath, host.maxExactPaths)
|
|
107
117
|
);
|
|
118
|
+
host.freshEvents.add(collectionName);
|
|
108
119
|
scheduleFlush(host, collectionName);
|
|
109
120
|
}
|
|
110
121
|
|
|
@@ -123,6 +134,7 @@ export function enqueueDirtyHint(
|
|
|
123
134
|
collectionName,
|
|
124
135
|
queueDirtyHint(pending, hint, host.maxDirtyHints)
|
|
125
136
|
);
|
|
137
|
+
host.freshEvents.add(collectionName);
|
|
126
138
|
scheduleFlush(host, collectionName);
|
|
127
139
|
}
|
|
128
140
|
|
|
@@ -152,9 +164,17 @@ export function scheduleFlush(
|
|
|
152
164
|
if (host.disposed()) {
|
|
153
165
|
return;
|
|
154
166
|
}
|
|
155
|
-
|
|
156
|
-
if (
|
|
157
|
-
|
|
167
|
+
const retryKind = host.retryScheduled.get(collectionName);
|
|
168
|
+
if (retryKind !== undefined) {
|
|
169
|
+
// Explicit retry owns the single timer; do not replace it with debounce.
|
|
170
|
+
if (retryKind === "fixed" || !host.freshEvents.has(collectionName)) {
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
// A fresh event never waits out a failure backoff: drop the retry timer and
|
|
174
|
+
// flush on the normal debounce. The failure count stays until a flush succeeds.
|
|
175
|
+
// A fixed (lease) retry keeps its timer so a held lease is not probed per event.
|
|
176
|
+
host.retryScheduled.delete(collectionName);
|
|
177
|
+
host.flushDeadlineAt.delete(collectionName);
|
|
158
178
|
}
|
|
159
179
|
const schedule = computeFlushDelay({
|
|
160
180
|
nowMs: host.clock(),
|
|
@@ -213,6 +233,8 @@ export function startFlush(host: WatchQueueHost, collectionName: string): void {
|
|
|
213
233
|
* Re-arm pending work after a file-level failure with retry backoff.
|
|
214
234
|
* At most one retry timer per collection; finally must not startFlush while set.
|
|
215
235
|
* forceFallback/overflow survive until forced classification + sync succeed.
|
|
236
|
+
* Without an explicit delay, each consecutive failure doubles the wait (capped),
|
|
237
|
+
* so work that fails the same way every time cannot spin the resident.
|
|
216
238
|
*/
|
|
217
239
|
export function requeueAfterFailure(
|
|
218
240
|
host: WatchQueueHost,
|
|
@@ -220,7 +242,7 @@ export function requeueAfterFailure(
|
|
|
220
242
|
exact: string[],
|
|
221
243
|
dirty: string[],
|
|
222
244
|
forceFlags?: PendingForceFlags,
|
|
223
|
-
delayMs
|
|
245
|
+
delayMs?: number
|
|
224
246
|
): void {
|
|
225
247
|
queueWithoutSchedule(host, collectionName, exact, dirty, forceFlags);
|
|
226
248
|
if (host.disposed()) {
|
|
@@ -230,7 +252,19 @@ export function requeueAfterFailure(
|
|
|
230
252
|
// Pending already merged; existing retry timer remains the sole attempt.
|
|
231
253
|
return;
|
|
232
254
|
}
|
|
233
|
-
host.retryScheduled.
|
|
255
|
+
host.retryScheduled.set(
|
|
256
|
+
collectionName,
|
|
257
|
+
delayMs === undefined ? "backoff" : "fixed"
|
|
258
|
+
);
|
|
259
|
+
let retryDelayMs = delayMs;
|
|
260
|
+
if (retryDelayMs === undefined) {
|
|
261
|
+
const failures = (host.retryFailures.get(collectionName) ?? 0) + 1;
|
|
262
|
+
host.retryFailures.set(collectionName, failures);
|
|
263
|
+
// Events that arrived while the failed flush ran flush on the debounce.
|
|
264
|
+
retryDelayMs = host.freshEvents.has(collectionName)
|
|
265
|
+
? host.flushDebounceMs
|
|
266
|
+
: watcherRetryDelayMs(failures);
|
|
267
|
+
}
|
|
234
268
|
const existingTimer = host.timers.get(collectionName);
|
|
235
269
|
if (existingTimer) {
|
|
236
270
|
clearTimeout(existingTimer);
|
|
@@ -242,7 +276,7 @@ export function requeueAfterFailure(
|
|
|
242
276
|
host.timers.delete(collectionName);
|
|
243
277
|
host.retryScheduled.delete(collectionName);
|
|
244
278
|
startFlush(host, collectionName);
|
|
245
|
-
},
|
|
279
|
+
}, retryDelayMs)
|
|
246
280
|
);
|
|
247
281
|
}
|
|
248
282
|
|
|
@@ -8,7 +8,11 @@ import type { FSWatcher } from "node:fs";
|
|
|
8
8
|
|
|
9
9
|
import type { Collection } from "../config/types";
|
|
10
10
|
import type { SyncOptions } from "../ingestion";
|
|
11
|
-
import type {
|
|
11
|
+
import type {
|
|
12
|
+
WatchEventHost,
|
|
13
|
+
WatchQueueHost,
|
|
14
|
+
WatcherRetryKind,
|
|
15
|
+
} from "./watch-service-events";
|
|
12
16
|
import type { WatchLifecycleHost } from "./watch-service-lifecycle";
|
|
13
17
|
import type { CollectionPending } from "./watch-service-state";
|
|
14
18
|
import type { WatcherSnapshot } from "./watch-snapshot";
|
|
@@ -46,7 +50,9 @@ export interface WatchServiceHostState {
|
|
|
46
50
|
maxDirtyHints: number;
|
|
47
51
|
flushDeadlineAt: Map<string, number>;
|
|
48
52
|
timers: Map<string, ReturnType<typeof setTimeout>>;
|
|
49
|
-
retryScheduled:
|
|
53
|
+
retryScheduled: Map<string, WatcherRetryKind>;
|
|
54
|
+
retryFailures: Map<string, number>;
|
|
55
|
+
freshEvents: Set<string>;
|
|
50
56
|
inFlightSyncs: Set<Promise<void>>;
|
|
51
57
|
runFlush: (collectionName: string) => Promise<void>;
|
|
52
58
|
}
|
|
@@ -71,6 +77,8 @@ export function buildLifecycleHost(
|
|
|
71
77
|
snapshotInit: state.snapshotInit,
|
|
72
78
|
syncing: state.syncing,
|
|
73
79
|
pendingByCollection: state.pendingByCollection,
|
|
80
|
+
retryFailures: state.retryFailures,
|
|
81
|
+
freshEvents: state.freshEvents,
|
|
74
82
|
clearCollectionRuntimeState: state.clearCollectionRuntimeState,
|
|
75
83
|
beginSnapshotInit: state.beginSnapshotInit,
|
|
76
84
|
watchFactory: state.watchFactory,
|
|
@@ -102,6 +110,8 @@ export function buildQueueHost(state: WatchServiceHostState): WatchQueueHost {
|
|
|
102
110
|
flushDeadlineAt: state.flushDeadlineAt,
|
|
103
111
|
timers: state.timers,
|
|
104
112
|
retryScheduled: state.retryScheduled,
|
|
113
|
+
retryFailures: state.retryFailures,
|
|
114
|
+
freshEvents: state.freshEvents,
|
|
105
115
|
snapshotReady: state.snapshotReady,
|
|
106
116
|
inFlightSyncs: state.inFlightSyncs,
|
|
107
117
|
runFlush: state.runFlush,
|
|
@@ -38,6 +38,10 @@ export interface WatchLifecycleHost {
|
|
|
38
38
|
* forceFallback + durable generation reconcile so a new baseline cannot absorb it.
|
|
39
39
|
*/
|
|
40
40
|
pendingByCollection: Map<string, CollectionPending>;
|
|
41
|
+
/** Consecutive failed flushes per collection (failure backoff input). */
|
|
42
|
+
retryFailures: Map<string, number>;
|
|
43
|
+
/** Collections whose queued work is new user action, not a failure retry. */
|
|
44
|
+
freshEvents: Set<string>;
|
|
41
45
|
clearCollectionRuntimeState: (collectionName: string) => void;
|
|
42
46
|
beginSnapshotInit: (collection: Collection) => void;
|
|
43
47
|
watchFactory: (
|
|
@@ -186,6 +190,10 @@ export function applyCollectionUpdate(
|
|
|
186
190
|
pending.forceFallback = true;
|
|
187
191
|
}
|
|
188
192
|
host.pendingByCollection.set(collection.name, pending);
|
|
193
|
+
// A config edit is user action that may fix the failure cause: it must
|
|
194
|
+
// not wait out an armed failure backoff, and the count starts over.
|
|
195
|
+
host.freshEvents.add(collection.name);
|
|
196
|
+
host.retryFailures.delete(collection.name);
|
|
189
197
|
}
|
|
190
198
|
if (host.watchers.has(collection.name)) {
|
|
191
199
|
host.beginSnapshotInit(collection);
|
|
@@ -10,7 +10,7 @@ import { normalize } from "node:path";
|
|
|
10
10
|
import type { Collection } from "../config/types";
|
|
11
11
|
import type { CollectionSyncResult, SyncOptions } from "../ingestion";
|
|
12
12
|
import type { SqliteAdapter } from "../store/sqlite/adapter";
|
|
13
|
-
import type { WatchQueueHost } from "./watch-service-events";
|
|
13
|
+
import type { WatchQueueHost, WatcherRetryKind } from "./watch-service-events";
|
|
14
14
|
import type { CollectionPending } from "./watch-service-state";
|
|
15
15
|
import type { WatcherSnapshot, WatcherSnapshotFs } from "./watch-snapshot";
|
|
16
16
|
|
|
@@ -36,7 +36,7 @@ export interface RunFlushContext {
|
|
|
36
36
|
pendingByCollection: Map<string, CollectionPending>;
|
|
37
37
|
flushDeadlineAt: Map<string, number>;
|
|
38
38
|
syncing: Set<string>;
|
|
39
|
-
retryScheduled:
|
|
39
|
+
retryScheduled: Map<string, WatcherRetryKind>;
|
|
40
40
|
collectionGenerations: Map<string, number>;
|
|
41
41
|
snapshots: Map<string, WatcherSnapshot>;
|
|
42
42
|
snapshotReady: Map<string, boolean>;
|
|
@@ -125,6 +125,7 @@ export async function runOwnedCollectionFlush(
|
|
|
125
125
|
}
|
|
126
126
|
|
|
127
127
|
// Events that arrived while the lease was being taken join this flush.
|
|
128
|
+
ctx.queueHost.freshEvents.delete(collectionName);
|
|
128
129
|
const taken = takePending(
|
|
129
130
|
ctx.pendingByCollection.get(collectionName) ?? pending
|
|
130
131
|
);
|
|
@@ -148,6 +149,9 @@ export async function runOwnedCollectionFlush(
|
|
|
148
149
|
);
|
|
149
150
|
};
|
|
150
151
|
|
|
152
|
+
// A flush can requeue failed work (e.g. a dirty classification error) and
|
|
153
|
+
// still settle as synced/idle; that must not reset the failure backoff.
|
|
154
|
+
let requeuedFailure = false;
|
|
151
155
|
try {
|
|
152
156
|
const outcome = await flushCollectionOnce({
|
|
153
157
|
collection,
|
|
@@ -218,6 +222,7 @@ export async function runOwnedCollectionFlush(
|
|
|
218
222
|
if (!stillOwner()) {
|
|
219
223
|
return;
|
|
220
224
|
}
|
|
225
|
+
requeuedFailure = true;
|
|
221
226
|
requeueAfterFailure(
|
|
222
227
|
ctx.queueHost,
|
|
223
228
|
collectionName,
|
|
@@ -236,6 +241,12 @@ export async function runOwnedCollectionFlush(
|
|
|
236
241
|
requeueGenerationReconcile(ctx.queueHost, collectionName);
|
|
237
242
|
},
|
|
238
243
|
});
|
|
244
|
+
if (
|
|
245
|
+
(outcome.status === "synced" || outcome.status === "idle") &&
|
|
246
|
+
!requeuedFailure
|
|
247
|
+
) {
|
|
248
|
+
ctx.queueHost.retryFailures.delete(collectionName);
|
|
249
|
+
}
|
|
239
250
|
if (
|
|
240
251
|
outcome.status === "failed" &&
|
|
241
252
|
outcome.error &&
|
|
@@ -15,6 +15,7 @@ import type { CollectionSyncResult, SyncOptions } from "../ingestion";
|
|
|
15
15
|
import type { SqliteAdapter } from "../store/sqlite/adapter";
|
|
16
16
|
import type { DocumentEvent, DocumentEventBus } from "./doc-events";
|
|
17
17
|
import type { EmbedScheduler } from "./embed-scheduler";
|
|
18
|
+
import type { WatcherRetryKind } from "./watch-service-events";
|
|
18
19
|
import type {
|
|
19
20
|
WatcherSnapshot,
|
|
20
21
|
WatcherSnapshotBuildResult,
|
|
@@ -126,7 +127,9 @@ export class CollectionWatchService {
|
|
|
126
127
|
readonly #pendingByCollection = new Map<string, CollectionPending>();
|
|
127
128
|
readonly #timers = new Map<string, ReturnType<typeof setTimeout>>();
|
|
128
129
|
readonly #flushDeadlineAt = new Map<string, number>();
|
|
129
|
-
readonly #retryScheduled = new
|
|
130
|
+
readonly #retryScheduled = new Map<string, WatcherRetryKind>();
|
|
131
|
+
readonly #retryFailures = new Map<string, number>();
|
|
132
|
+
readonly #freshEvents = new Set<string>();
|
|
130
133
|
readonly #syncing = new Set<string>();
|
|
131
134
|
readonly #inFlightSyncs = new Set<Promise<void>>();
|
|
132
135
|
readonly #suppressedPaths = new Map<string, number>();
|
|
@@ -216,6 +219,8 @@ export class CollectionWatchService {
|
|
|
216
219
|
this.#timers.clear();
|
|
217
220
|
this.#flushDeadlineAt.clear();
|
|
218
221
|
this.#retryScheduled.clear();
|
|
222
|
+
this.#retryFailures.clear();
|
|
223
|
+
this.#freshEvents.clear();
|
|
219
224
|
this.#watchers.clear();
|
|
220
225
|
this.#watchRoots.clear();
|
|
221
226
|
this.#collectionGenerations.clear();
|
|
@@ -303,6 +308,8 @@ export class CollectionWatchService {
|
|
|
303
308
|
flushDeadlineAt: this.#flushDeadlineAt,
|
|
304
309
|
timers: this.#timers,
|
|
305
310
|
retryScheduled: this.#retryScheduled,
|
|
311
|
+
retryFailures: this.#retryFailures,
|
|
312
|
+
freshEvents: this.#freshEvents,
|
|
306
313
|
inFlightSyncs: this.#inFlightSyncs,
|
|
307
314
|
runFlush: (name) => this.#flushCollection(name),
|
|
308
315
|
};
|
|
@@ -316,6 +323,8 @@ export class CollectionWatchService {
|
|
|
316
323
|
this.#snapshotInit.delete(collectionName);
|
|
317
324
|
this.#flushDeadlineAt.delete(collectionName);
|
|
318
325
|
this.#retryScheduled.delete(collectionName);
|
|
326
|
+
this.#retryFailures.delete(collectionName);
|
|
327
|
+
this.#freshEvents.delete(collectionName);
|
|
319
328
|
const timer = this.#timers.get(collectionName);
|
|
320
329
|
if (timer) {
|
|
321
330
|
clearTimeout(timer);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
2d8fa6721fe305e2fd70450405e255900d028b187c884bbf74f29a3a33d27d3c gno-browser-clipper-v2.9.0.zip
|