@zukhruf/single-flight 0.3.18 → 0.3.20

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 CHANGED
@@ -70,7 +70,7 @@ The lease that the work gets comes from `@zukhruf/lease`, and its token comes fr
70
70
 
71
71
  ## The directory
72
72
 
73
- The directory is the local folder where the processes that share flights meet. Each process that uses a `SingleFlight` keeps three files there: `flight.lock`, `flight.epoch` and `flight.sock`. The election of [`@zukhruf/election`](../election/README.md) claims `flight.lock` with a file lock, and records the epoch of the last term in `flight.epoch`. The journal of the claim is in memory, so a coordinator that stops leaves no `flight.lock-journal` file. All the processes that name the same directory are one group, and the callers of one key share a flight in that group only.
73
+ The directory is the local folder where the processes that share flights meet. Each process that uses a `SingleFlight` keeps four files there: `flight.lock`, `flight.epoch`, `flight.lock.clean` and `flight.sock`. The election of [`@zukhruf/election`](../election/README.md) claims `flight.lock` with a file lock, and records the epoch of the last term in `flight.epoch`. After a clean shutdown of a coordinator, `flight.lock.clean` holds the epoch of its term until the next term starts. The journal of the claim is in memory, so a coordinator that stops leaves no `flight.lock-journal` file. All the processes that name the same directory are one group, and the callers of one key share a flight in that group only.
74
74
 
75
75
  There is no default directory. One default would put each application on the host into one group, and unrelated applications that use the same key would join each other's flights. Give each group its own directory, for example a folder of your application's data.
76
76
 
@@ -89,11 +89,11 @@ The work gets the lease of the flight:
89
89
  - `token`: a `FencingToken`. Its high 32 bits are the epoch of the coordinator's term, so a newer term always gives higher tokens.
90
90
  - `signal`: it aborts with `LeaseLostError` when the flight is no longer the leader's. The `subject` of the error is the key. This occurs when the leader misses the grace window of a new coordinator.
91
91
 
92
- | Option | What it does |
93
- | ------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
94
- | `directory` | The local folder where the processes of one group meet. See [The directory](#the-directory). |
95
- | `codec` | Turns the value of a flight into text for the joiners, and back. See [The codec](#the-codec). |
96
- | `graceWindow` | Milliseconds that a new coordinator starts no flight, so the leaders of the flights in progress can reassert them. It must be longer than a process takes to connect again. Defaults to `500`. |
92
+ | Option | What it does |
93
+ | ------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
94
+ | `directory` | The local folder where the processes of one group meet. See [The directory](#the-directory). |
95
+ | `codec` | Turns the value of a flight into text for the joiners, and back. See [The codec](#the-codec). |
96
+ | `graceWindow` | Milliseconds that a new coordinator starts no flight, so the leaders of the flights in progress can reassert them. It must be longer than a process takes to connect again. A coordinator after a clean shutdown has none. Defaults to `500`. |
97
97
 
98
98
  `flights[Symbol.asyncDispose]()` waits until each landing of this process reached a coordinator, and then it disconnects. When this process is the coordinator, the other processes elect a new one.
99
99
 
@@ -157,6 +157,8 @@ A codec that cannot encode the value fails the flight for all callers. A codec t
157
157
 
158
158
  A joiner in the leader's own process is a joiner too: it gets `FlightFailedError`, not the original error. `FlightFailedError` has the `key` and the `failure`: the `name`, the `message` and the `code` of the error. A thrown value that is not an error keeps only its text.
159
159
 
160
+ `LeaseLostError` is the class of [`@zukhruf/lease`](../lease/README.md). This package exports it too, because the call of a leader rejects with it.
161
+
160
162
  ## Cancel a wait
161
163
 
162
164
  Give a signal to stop the wait of one caller: `flights.run(key, work, { signal: AbortSignal.timeout(30_000) })`. The call rejects with the reason of the signal. The flight continues for the other callers. When the caller of the leader cancels, the work continues and lands for the joiners. A call whose signal aborted before the call rejects at once: it never leads and never joins. [ADR 0004](./docs/adr/0004-a-cancel-withdraws-only-its-caller.md) tells why.
@@ -164,7 +166,8 @@ Give a signal to stop the wait of one caller: `flights.run(key, work, { signal:
164
166
  ## When a process stops
165
167
 
166
168
  - **The process of a leader stops.** The coordinator tells each joiner that the flight is interrupted, and each joiner rejects with `FlightInterruptedError` at once. No joiner runs the work again. The next call of the key leads a new flight.
167
- - **The coordinator stops.** The other processes elect a new coordinator. Its term starts with a grace window. In the grace window:
169
+ - **The coordinator disposes with nothing in progress.** This is a clean shutdown: no flight is in progress, and the grace window of the coordinator is over, or it had none. The next coordinator then has no grace window, and each call leads or joins at once. [ADR 0009](./docs/adr/0009-the-next-coordinator-skips-the-grace-window-after-a-clean-shutdown.md) tells why.
170
+ - **The coordinator stops in another way.** For example, its process stops, or it disposes while a flight is in progress. The other processes elect a new coordinator. Its term starts with a grace window. In the grace window:
168
171
  - Each leader reasserts its flight, and sends its landing again when it has one.
169
172
  - Each joiner rejoins its flight by the flight's token, and it gets the outcome of that flight.
170
173
  - A new call waits for the grace window to end. Then it leads or joins.
@@ -194,6 +197,7 @@ Version 0.3.13 to 0.3.15 had a pull design. These parts changed:
194
197
  - [ADR 0006: The election and the connection are a copy of the mutex code](./docs/adr/0006-the-election-and-the-connection-are-a-copy-of-the-mutex-code.md)
195
198
  - [ADR 0007: A work error after a lost lease rejects with LeaseLostError](./docs/adr/0007-a-work-error-after-a-lost-lease-rejects-with-leaselosterror.md)
196
199
  - [ADR 0008: A connection closes only when its framing breaks](./docs/adr/0008-a-connection-closes-only-when-its-framing-breaks.md)
200
+ - [ADR 0009: The next coordinator skips the grace window after a clean shutdown](./docs/adr/0009-the-next-coordinator-skips-the-grace-window-after-a-clean-shutdown.md)
197
201
  - [Code copied from the mutex](./docs/copied-from-mutex.md): each copied file, what changed, and why; the rules that the single flight shares with the mutex; and the code that is in two places inside the single flight.
198
202
  - Superseded: [ADR 0001](./docs/adr/0001-a-joiner-follows-its-flight-record-without-acquiring-the-key.md) and [ADR 0002](./docs/adr/0002-a-flight-that-all-callers-left-is-abandoned.md).
199
203
 
@@ -8,8 +8,8 @@ export interface FlightCoordinatorOptions {
8
8
  tokens: TokenSource;
9
9
  /**
10
10
  * Milliseconds after start during which no flight starts, so leaders from a
11
- * previous coordinator can reassert their flights first. Zero for a
12
- * coordinator that never replaces another.
11
+ * previous coordinator can reassert their flights first. Zero when no
12
+ * earlier coordinator can have left a flight in progress.
13
13
  */
14
14
  graceWindow: number;
15
15
  }
@@ -21,6 +21,11 @@ export interface FlightCoordinatorOptions {
21
21
  export declare class FlightCoordinator {
22
22
  #private;
23
23
  constructor({ tokens, graceWindow }: FlightCoordinatorOptions);
24
+ /**
25
+ * Whether the next coordinator would find nothing to recover: no flight is
26
+ * in progress, and the grace window is over or there was none.
27
+ */
28
+ get leavesNothingToRecover(): boolean;
24
29
  serve(connection: Connection<FlightResponse>): void;
25
30
  run(party: Party, key: string): Promise<void>;
26
31
  /** A joiner that lost its connection, back for the flight it joined: it never leads, so its work never runs twice. */
@@ -1 +1 @@
1
- {"version":3,"file":"flight-coordinator.d.ts","sourceRoot":"","sources":["../../src/coordinator/flight-coordinator.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAElE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,KAAK,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,gCAAgC,CAAC;AAC9E,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAGxC,MAAM,WAAW,wBAAwB;IACvC,oEAAoE;IACpE,MAAM,EAAE,WAAW,CAAC;IACpB;;;;OAIG;IACH,WAAW,EAAE,MAAM,CAAC;CACrB;AAUD;;;;GAIG;AACH,qBAAa,iBAAiB;;gBAGhB,EAAE,MAAM,EAAE,WAAW,EAAE,EAAE,wBAAwB;IAgB7D,KAAK,CAAC,UAAU,EAAE,UAAU,CAAC,cAAc,CAAC,GAAG,IAAI;IAInD,GAAG,CAAC,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAI7C,sHAAsH;IACtH,MAAM,CAAC,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIhE,QAAQ,CAAC,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE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,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,IAAI;IAI5C,qDAAqD;IACrD,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;CAGhC"}
@@ -24,6 +24,13 @@ export class FlightCoordinator {
24
24
  this.#phase = coordinating;
25
25
  }
26
26
  }
27
+ /**
28
+ * Whether the next coordinator would find nothing to recover: no flight is
29
+ * in progress, and the grace window is over or there was none.
30
+ */
31
+ get leavesNothingToRecover() {
32
+ return this.#phase.leavesNothingToRecover;
33
+ }
27
34
  serve(connection) {
28
35
  new Session(this, connection);
29
36
  }
@@ -53,6 +60,9 @@ class Coordinating {
53
60
  this.#flights = flights;
54
61
  this.#tokens = tokens;
55
62
  }
63
+ get leavesNothingToRecover() {
64
+ return this.#flights.size === 0;
65
+ }
56
66
  async run(party, key) {
57
67
  // A token that goes unused is harmless: tokens only need to grow.
58
68
  const token = await this.#tokens.next(key);
@@ -105,6 +115,10 @@ class GraceWindow {
105
115
  this.#over = over;
106
116
  this.#next = next;
107
117
  }
118
+ /** A leader of the previous term may not have reasserted its flight yet, so this coordinator cannot know. */
119
+ get leavesNothingToRecover() {
120
+ return false;
121
+ }
108
122
  /** A fresh run leads or joins only once every leader had its chance to reassert. */
109
123
  async run(party, key) {
110
124
  await this.#over.wait();
@@ -1 +1 @@
1
- {"version":3,"file":"flight-coordinator.js","sourceRoot":"","sources":["../../src/coordinator/flight-coordinator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAKvC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAqBvC;;;;GAIG;AACH,MAAM,OAAO,iBAAiB;IAC5B,MAAM,CAAQ;IAEd,YAAY,EAAE,MAAM,EAAE,WAAW,EAA4B;QAC3D,MAAM,OAAO,GAAG,IAAI,GAAG,EAAkB,CAAC;QAC1C,MAAM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CAAC,GAAG,EAAE,CAAC,MAAM,GAAG,IAAI,GAAG,EAAE,CAAC,CAAC,CAAC;QACzD,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC;QACxC,OAAO,OAAO,CAAC;IACjB,CAAC;CACF"}
@@ -20,8 +20,10 @@ export declare class FlightServer {
20
20
  * Each connection ends only after what was written to it, such as an
21
21
  * outcome for a joiner, is sent. The term ends only after the socket is
22
22
  * gone: in the other order, this close could remove a successor's socket file.
23
+ * The term resigns clean when the coordinator leaves nothing to recover, so
24
+ * the successor skips its grace window; a lost term records nothing.
23
25
  * The first call removes the file at once, so a second caller finds it gone,
24
- * and it too resolves only once the term ended.
26
+ * and it too resolves only once the term ended as the first call ended it.
25
27
  */
26
28
  close(): Promise<void>;
27
29
  }
@@ -1 +1 @@
1
- {"version":3,"file":"flight-server.d.ts","sourceRoot":"","sources":["../../src/coordinator/flight-server.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAQ9C,MAAM,WAAW,mBAAmB;IAClC,qGAAqG;IACrG,WAAW,EAAE,MAAM,CAAC;CACrB;AAED;;;;;GAKG;AACH,qBAAa,YAAY;;IAMvB,OAAO;WAOM,KAAK,CAChB,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,IAAI,EACV,EAAE,WAAW,EAAE,EAAE,mBAAmB,GACnC,OAAO,CAAC,YAAY,CAAC;IAkCxB;;;;;;;;;OASG;IACG,KAAK;CAOZ"}
1
+ {"version":3,"file":"flight-server.d.ts","sourceRoot":"","sources":["../../src/coordinator/flight-server.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAQ9C,MAAM,WAAW,mBAAmB;IAClC,qGAAqG;IACrG,WAAW,EAAE,MAAM,CAAC;CACrB;AAED;;;;;GAKG;AACH,qBAAa,YAAY;;IAOvB,OAAO;WAaM,KAAK,CAChB,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,IAAI,EACV,EAAE,WAAW,EAAE,EAAE,mBAAmB,GACnC,OAAO,CAAC,YAAY,CAAC;IAkCxB;;;;;;;;;;;OAWG;IACG,KAAK;CAaZ"}
@@ -14,11 +14,13 @@ import { FlightCoordinator } from "./flight-coordinator.js";
14
14
  export class FlightServer {
15
15
  #server;
16
16
  #connections;
17
+ #coordinator;
17
18
  #term;
18
19
  #closeOnLoss;
19
- constructor(server, connections, term) {
20
+ constructor(server, connections, coordinator, term) {
20
21
  this.#server = server;
21
22
  this.#connections = connections;
23
+ this.#coordinator = coordinator;
22
24
  this.#term = term;
23
25
  this.#closeOnLoss = addAbortListener(term.signal, () => void this.close());
24
26
  }
@@ -48,7 +50,7 @@ export class FlightServer {
48
50
  server.listen(socketPath);
49
51
  await once(server, 'listening');
50
52
  server.unref();
51
- const started = new FlightServer(server, connections, term);
53
+ const started = new FlightServer(server, connections, coordinator, term);
52
54
  // The term may have been lost while the server started.
53
55
  if (term.signal.aborted) {
54
56
  await started.close();
@@ -63,16 +65,24 @@ export class FlightServer {
63
65
  * Each connection ends only after what was written to it, such as an
64
66
  * outcome for a joiner, is sent. The term ends only after the socket is
65
67
  * gone: in the other order, this close could remove a successor's socket file.
68
+ * The term resigns clean when the coordinator leaves nothing to recover, so
69
+ * the successor skips its grace window; a lost term records nothing.
66
70
  * The first call removes the file at once, so a second caller finds it gone,
67
- * and it too resolves only once the term ended.
71
+ * and it too resolves only once the term ended as the first call ended it.
68
72
  */
69
73
  async close() {
70
74
  this.#closeOnLoss[Symbol.dispose]();
71
75
  const closed = this.#server[Symbol.asyncDispose]();
76
+ // Read in the step that ends the connections: each session that ends
77
+ // withdraws its flights, so later there is never a flight in progress.
78
+ // An answer written after this step, such as the `lead` of a run whose
79
+ // token is being minted, never reaches its client, which sends the run
80
+ // again to the successor. So no client knows of a flight this read missed.
81
+ const clean = this.#coordinator.leavesNothingToRecover;
72
82
  for (const socket of this.#connections)
73
83
  socket.destroySoon();
74
84
  await closed;
75
- await this.#term.resign();
85
+ await this.#term.resign({ clean });
76
86
  }
77
87
  }
78
88
  //# sourceMappingURL=flight-server.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"flight-server.js","sourceRoot":"","sources":["../../src/coordinator/flight-server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AACtC,OAAO,EAA4B,YAAY,EAAE,MAAM,UAAU,CAAC;AAGlE,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEpD,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAEtE,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAO5D;;;;;GAKG;AACH,MAAM,OAAO,YAAY;IACd,OAAO,CAAS;IAChB,YAAY,CAAc;IAC1B,KAAK,CAAO;IACZ,YAAY,CAAa;IAElC,YAAoB,MAAc,EAAE,WAAwB,EAAE,IAAU;QACtE,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,YAAY,GAAG,WAAW,CAAC;QAChC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,YAAY,GAAG,gBAAgB,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,KAAK,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC;IAC7E,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,KAAK,CAChB,UAAkB,EAClB,IAAU,EACV,EAAE,WAAW,EAAuB;QAEpC,2GAA2G;QAC3G,sFAAsF;QACtF,IAAI,OAAO,CAAC,QAAQ,KAAK,OAAO,EAAE,CAAC;YACjC,MAAM,EAAE,CAAC,UAAU,EAAE,EAAE,KA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AAC;QACzE,wDAAwD;QACxD,IAAI,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;YACxB,MAAM,OAAO,CAAC,KAAK,EAAE,CAAC;YACtB,IAAI,CAAC,MAAM,CAAC,cAAc,EAAE,CAAC;QAC/B,CAAC;QACD,OAAO,OAAO,CAAC;IACjB,CAAC;IAED;;;;;;;;;;;OAWG;IACH,KAAK,CAAC,KAAK;QACT,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC;QACpC,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,EAAE,CAAC;QACnD,qEAAqE;QACrE,uEAAuE;QACvE,uEAAuE;QACvE,uEAAuE;QACvE,2EAA2E;QAC3E,MAAM,KAAK,GAAG,IAAI,CAAC,YAAY,CAAC,sBAAsB,CAAC;QACvD,KAAK,MAAM,MAAM,IAAI,IAAI,CAAC,YAAY;YAAE,MAAM,CAAC,WAAW,EAAE,CAAC;QAC7D,MAAM,MAAM,CAAC;QACb,MAAM,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;IACrC,CAAC;CACF"}
package/dist/index.d.ts CHANGED
@@ -4,4 +4,5 @@ export type { Failure } from './protocol/flight-protocol.ts';
4
4
  export { FlightFailedError, FlightInterruptedError } from './errors.ts';
5
5
  export { ProtocolVersionError } from './connection/protocol-version-error.ts';
6
6
  export { NetworkDirectoryError } from '@zukhruf/fs';
7
+ export { LeaseLostError } from '@zukhruf/lease';
7
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,YAAY,EACZ,KAAK,mBAAmB,GACzB,MAAM,oBAAoB,CAAC;AAC5B,YAAY,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACxC,YAAY,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AAC7D,OAAO,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AACxE,OAAO,EAAE,oBAAoB,EAAE,MAAM,wCAAwC,CAAC;AAC9E,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,YAAY,EACZ,KAAK,mBAAmB,GACzB,MAAM,oBAAoB,CAAC;AAC5B,YAAY,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACxC,YAAY,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AAC7D,OAAO,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AACxE,OAAO,EAAE,oBAAoB,EAAE,MAAM,wCAAwC,CAAC;AAC9E,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC"}
package/dist/index.js CHANGED
@@ -2,4 +2,5 @@ export { SingleFlight, } from "./single-flight.js";
2
2
  export { FlightFailedError, FlightInterruptedError } from "./errors.js";
3
3
  export { ProtocolVersionError } from "./connection/protocol-version-error.js";
4
4
  export { NetworkDirectoryError } from '@zukhruf/fs';
5
+ export { LeaseLostError } from '@zukhruf/lease';
5
6
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,YAAY,GAEb,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AACxE,OAAO,EAAE,oBAAoB,EAAE,MAAM,wCAAwC,CAAC;AAC9E,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,YAAY,GAEb,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AACxE,OAAO,EAAE,oBAAoB,EAAE,MAAM,wCAAwC,CAAC;AAC9E,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC"}
@@ -3,7 +3,8 @@ import type { Codec } from './codec.ts';
3
3
  export interface SingleFlightOptions<T> {
4
4
  /**
5
5
  * The local folder where the processes that share flights meet. They keep
6
- * `flight.lock`, `flight.epoch` and `flight.sock` there, so every process
6
+ * `flight.lock`, `flight.epoch`, `flight.lock.clean` and `flight.sock`
7
+ * there, so every process
7
8
  * that names the same folder is in one group, and callers of one key share
8
9
  * a flight across that group. There is no default: one shared default would
9
10
  * put every application on the host into one group, and unrelated
@@ -16,7 +17,8 @@ export interface SingleFlightOptions<T> {
16
17
  /**
17
18
  * Milliseconds that a new coordinator starts no flight after the previous
18
19
  * one stopped, so the leaders of flights in progress can claim them again.
19
- * Must exceed how long a process takes to reconnect. Defaults to 500.
20
+ * A coordinator after a clean shutdown of the one before has none. Must
21
+ * exceed how long a process takes to reconnect. Defaults to 500.
20
22
  */
21
23
  graceWindow?: number;
22
24
  }
@@ -1 +1 @@
1
- {"version":3,"file":"single-flight.d.ts","sourceRoot":"","sources":["../src/single-flight.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAIpD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAiBxC,MAAM,WAAW,mBAAmB,CAAC,CAAC;IACpC;;;;;;;;OAQG;IACH,SAAS,EAAE,MAAM,CAAC;IAClB,qFAAqF;IAC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AE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,UAAU;IACzB,8EAA8E;IAC9E,MAAM,CAAC,EAAE,CAAC,MAAM,IAAI,CAAC,GAAG,SAAS,CAAC;IAClC,uGAAuG;IACvG,MAAM,CAAC,EAAE,WAAW,GAAG,SAAS,CAAC;CAClC;AAED,mHAAmH;AACnH,MAAM,WAAW,WAAW,CAAC,CAAC;IAC5B,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAC;IAClB,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;CAC1B;AAKD;;;;;;GAMG;AACH,qBAAa,YAAY,CAAC,CAAC,CAAE,YAAW,eAAe;;gBAMzC,EAAE,SAAS,EAAE,KAAK,EAAE,WAAiB,EAAE,EAAE,mBAAmB,CAAC,CAAC,CAAC;IAkC3E;;;;;;;;OAQG;IACG,GAAG,CACP,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,OAAO,CAAC,CAAC,CAAC,EACxC,EAAE,MAAM,EAAE,MAAM,EAAE,GAAE,UAAe,GAClC,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;IAmB1B,gGAAgG;IAC1F,CAAC,MAAM,CAAC,YAAY,CAAC;CAmC5B"}
@@ -33,8 +33,12 @@ export class SingleFlight {
33
33
  // Until serving has fully started, a failure closes the new server, so no server outlives its term.
34
34
  await using starting = new AsyncDisposableStack();
35
35
  starting.adopt(await FlightServer.start(socketPath, term, {
36
- // The first term of a directory has no flights to wait for.
37
- graceWindow: term.epoch > 1n ? graceWindow : 0,
36
+ // The first term of a directory has no flights to wait for,
37
+ // and neither has a term after a clean shutdown: the
38
+ // coordinator before it left no flight in progress.
39
+ graceWindow: term.epoch > 1n && !term.afterCleanShutdown
40
+ ? graceWindow
41
+ : 0,
38
42
  }), (started) => started.close());
39
43
  this.#servers.use(starting.move());
40
44
  },
@@ -1 +1 @@
1
- {"version":3,"file":"single-flight.js","sourceRoot":"","sources":["../src/single-flight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AAK,KAAK,IAAI,CAAC,MAAM;gBAAE,OAAO,EAAE,KAAK,EAAE,CAAC;YAC7D,OAAO,EAAE,KAAK,EAAE,IAAI,cAAc,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;QAC9D,CAAC;QACD,0FAA0F;QAC1F,IAAI,IAAI,CAAC,OAAO;YAAE,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC;QAChD,IAAI,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;QAC3B,IAAI,CAAC;YACH,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC;QAC7C,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,EAAE,KAAK,EAAE,CAAC;QACnB,CAAC;IACH,CAAC;IAED,KAAK,CAAC,GAAW,EAAE,OAAgB;QACjC,IAAI,SAAS,IAAI,OAAO;YAAE,MAAM,IAAI,iBAAiB,CAAC,GAAG,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;QAC5E,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IAC3C,CAAC;CACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zukhruf/single-flight",
3
- "version": "0.3.18",
3
+ "version": "0.3.20",
4
4
  "description": "Callers of one key share the run already in flight, in one process or across the processes that use one directory, and get its outcome instead of a busy error.",
5
5
  "license": "MIT",
6
6
  "repository": {