@fairfox/polly 0.59.0 → 0.60.0
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.
|
@@ -23,7 +23,7 @@ import { Repo, type StorageAdapterInterface } from "@automerge/automerge-repo/sl
|
|
|
23
23
|
import type { KeyringStorage } from "./keyring-storage";
|
|
24
24
|
import { type MeshKeyring, MeshNetworkAdapter } from "./mesh-network-adapter";
|
|
25
25
|
import { MeshSignalingClient, type MeshSignalingClientOptions } from "./mesh-signaling-client";
|
|
26
|
-
import { type MeshStateLoadedRejectionBreadcrumb } from "./mesh-state";
|
|
26
|
+
import { type MeshStateLazyWrapperRecord, type MeshStateLoadedRejectionBreadcrumb } from "./mesh-state";
|
|
27
27
|
import { MeshWebRTCAdapter, type MeshWebRTCAdapterOptions } from "./mesh-webrtc-adapter";
|
|
28
28
|
/** Options for {@link createMeshClient}. */
|
|
29
29
|
export interface CreateMeshClientOptions {
|
|
@@ -255,6 +255,20 @@ export interface MeshStateModuleDiagnostics {
|
|
|
255
255
|
* silently. `undefined` means no rejection has escaped any
|
|
256
256
|
* wrapper on THIS module instance since module load. */
|
|
257
257
|
lastLoadedRejection: MeshStateLoadedRejectionBreadcrumb | undefined;
|
|
258
|
+
/** Polly#107 post-v0.59 instrumentation. Per-factory-invocation
|
|
259
|
+
* structured log — one record per `$mesh*` wrapper's lazy handle
|
|
260
|
+
* factory call, ring-buffered at 64 entries. Each row names the
|
|
261
|
+
* exit path (`returned-cached`, `loaded-from-storage`,
|
|
262
|
+
* `seeded-and-imported`, `threw`) and the synchronous peek at
|
|
263
|
+
* `repo.handles[docId]` taken in the factory's `finally`. The
|
|
264
|
+
* v0.59.0 fingerprint had `lazyInvocations === lazyReachedRepo`
|
|
265
|
+
* and no `lastLoadedRejection`; this field disambiguates which
|
|
266
|
+
* exit path each "successful" invocation actually took and
|
|
267
|
+
* whether the Repo registered the handle in spite of the lack of
|
|
268
|
+
* a thrown error. The smoking gun for H-Q1 is rows with
|
|
269
|
+
* `exitReason: "seeded-and-imported"` and
|
|
270
|
+
* `handleRegistered: false`. */
|
|
271
|
+
lazyWrappers: MeshStateLazyWrapperRecord[];
|
|
258
272
|
}
|
|
259
273
|
/** The mesh client's enriched per-peer state snapshot. Mirrors the
|
|
260
274
|
* underlying {@link MeshWebRTCAdapter.getPeerStateSnapshot} shape but
|
|
@@ -140,6 +140,69 @@ export interface MeshStateLoadedRejectionBreadcrumb {
|
|
|
140
140
|
/** Returns the most recent rejection escaping a `$meshState` factory
|
|
141
141
|
* invocation since module load. See {@link lastLoadedRejection}. */
|
|
142
142
|
export declare function getLastLoadedRejection(): MeshStateLoadedRejectionBreadcrumb | undefined;
|
|
143
|
+
/** Polly#107 post-v0.59 instrumentation. Categorises the exit path
|
|
144
|
+
* a `$mesh*` lazy factory invocation took. The v0.59.0 fingerprint
|
|
145
|
+
* showed `lazyInvocations === lazyReachedRepo === 17` and no
|
|
146
|
+
* `lastLoadedRejection` — every factory reached the first
|
|
147
|
+
* `repo.handles[docId]` access, none rejected loudly, yet 16 of 17
|
|
148
|
+
* handles never landed in `repo.handles`. Without per-exit detail
|
|
149
|
+
* the snapshot cannot disambiguate "factory returned the cached
|
|
150
|
+
* handle", "factory hydrated from storage", "factory seeded and
|
|
151
|
+
* imported a fresh doc", or "factory took the cached branch but
|
|
152
|
+
* `whenReady` resolved to `unavailable` and the code fell
|
|
153
|
+
* through". Each exit reason corresponds to a single line in
|
|
154
|
+
* {@link buildHandleFactory}; the snapshot record names it
|
|
155
|
+
* verbatim so the operator can grep the source from one read. */
|
|
156
|
+
export type LazyWrapperExitReason = "returned-cached" | "loaded-from-storage" | "seeded-and-imported" | "threw";
|
|
157
|
+
/** Polly#107 post-v0.59 instrumentation. One record per factory
|
|
158
|
+
* invocation, ring-buffered on the module and surfaced through
|
|
159
|
+
* `MeshClient.getPeerStateSnapshot()` as
|
|
160
|
+
* `meshStateModule.lazyWrappers`. The five fields together answer
|
|
161
|
+
* the post-v0.59 question "if every factory reached the Repo and
|
|
162
|
+
* nothing rejected, why are 16 of 17 handles absent from
|
|
163
|
+
* `repo.handles`?" — `exitReason` names which of the three success
|
|
164
|
+
* paths each took, `handleRegistered` is the synchronous peek at
|
|
165
|
+
* `repo.handles[docId]` taken in the factory's `finally` (i.e. at
|
|
166
|
+
* the moment of would-be return), and `handleState` is the
|
|
167
|
+
* lifecycle state observed in that peek. A row where
|
|
168
|
+
* `exitReason: "seeded-and-imported"` and `handleRegistered: false`
|
|
169
|
+
* is the smoking gun for H-Q1 (`repo.import` returned without
|
|
170
|
+
* registering); rows where `exitReason: "returned-cached"` repeats
|
|
171
|
+
* for sixteen of seventeen distinct keys indicates collisions or
|
|
172
|
+
* that the factory is being called multiple times against a
|
|
173
|
+
* Repo-state-machine that has already filled the slot. */
|
|
174
|
+
export interface MeshStateLazyWrapperRecord {
|
|
175
|
+
/** The logical application key passed to `$meshState(key, ...)`. */
|
|
176
|
+
key: string;
|
|
177
|
+
/** Stringified Automerge `DocumentId` derived from the key. */
|
|
178
|
+
docId: string;
|
|
179
|
+
/** `Date.now()` captured at the moment the factory was about to
|
|
180
|
+
* return (or rethrow). */
|
|
181
|
+
at: number;
|
|
182
|
+
/** Which of the four exit paths the factory took. See
|
|
183
|
+
* {@link LazyWrapperExitReason}. */
|
|
184
|
+
exitReason: LazyWrapperExitReason;
|
|
185
|
+
/** Snapshot peek `repo.handles[docId] !== undefined` taken in the
|
|
186
|
+
* factory's `finally` clause. `true` means the local Repo
|
|
187
|
+
* registered the handle; `false` means the factory thinks it
|
|
188
|
+
* succeeded but the Repo does not hold the handle for this
|
|
189
|
+
* documentId. The "polly#107 post-v0.59" smoking gun is
|
|
190
|
+
* `exitReason: "seeded-and-imported", handleRegistered: false`. */
|
|
191
|
+
handleRegistered: boolean;
|
|
192
|
+
/** Lifecycle state of `repo.handles[docId]` at the synchronous
|
|
193
|
+
* peek time. `undefined` when the handle was not registered.
|
|
194
|
+
* Useful for distinguishing the "registered as loading/unavailable"
|
|
195
|
+
* case from the "registered as ready" case. */
|
|
196
|
+
handleState: string | undefined;
|
|
197
|
+
/** Error message if `exitReason === "threw"`; `undefined`
|
|
198
|
+
* otherwise. The full rejection still flows into
|
|
199
|
+
* {@link lastLoadedRejection}; this field is the row-local
|
|
200
|
+
* summary so the snapshot can show the failure cause inline. */
|
|
201
|
+
errorMessage: string | undefined;
|
|
202
|
+
}
|
|
203
|
+
/** Returns a copy of the lazy-wrapper invocation log. See
|
|
204
|
+
* {@link MeshStateLazyWrapperRecord}. */
|
|
205
|
+
export declare function getLazyWrappers(): MeshStateLazyWrapperRecord[];
|
|
143
206
|
/**
|
|
144
207
|
* Create a peer-replicated state primitive backed by Automerge with a mesh
|
|
145
208
|
* transport. Every device holds a full replica; no central server holds a
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fairfox/polly",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.60.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "Multi-execution-context framework with reactive state and cross-context messaging for Chrome extensions, PWAs, and worker-based applications",
|