deepline 0.3.508 → 0.3.510
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/dist/bundling-sources/sdk/src/release.ts +1 -1
- package/dist/bundling-sources/shared_libs/monitors/org-monitor-limits.ts +7 -2
- package/dist/bundling-sources/shared_libs/observability/scheduled-jobs.json +1 -1
- package/dist/bundling-sources/shared_libs/play-runtime/db-session-plan.ts +47 -6
- package/dist/bundling-sources/shared_libs/play-runtime/deployment/commands/roll-execution-relay.ts +94 -43
- package/dist/bundling-sources/shared_libs/play-runtime/deployment/commands/roll-receipt-gateway.ts +111 -27
- package/dist/bundling-sources/shared_libs/play-runtime/deployment/commands/runtime-topology.ts +79 -6
- package/dist/bundling-sources/shared_libs/play-runtime/deployment/fly-machines.ts +80 -6
- package/dist/bundling-sources/shared_libs/play-runtime/deployment/fly-transient-retry.ts +571 -0
- package/dist/bundling-sources/shared_libs/plays/authoring-contract.ts +1 -0
- package/dist/cli/auth-S2Z5YMU3.js +43 -0
- package/dist/cli/{auth-2URIN52G.mjs → auth-USS2W3UV.mjs} +5 -5
- package/dist/cli/{billing-IW23GSR5.mjs → billing-JCUWM5XB.mjs} +7 -7
- package/dist/cli/{billing-R2HY2ZVJ.js → billing-LQQHU443.js} +82 -82
- package/dist/cli/{chunk-7PELFO3C.js → chunk-2JXEZAJF.js} +21 -21
- package/dist/cli/chunk-3LXU22UZ.js +77 -0
- package/dist/cli/{chunk-74UO7THC.js → chunk-4NJK6P5T.js} +4 -4
- package/dist/cli/{chunk-FXKKFM7J.js → chunk-4ZIIS6KG.js} +9 -9
- package/dist/cli/{chunk-63MCLOR2.mjs → chunk-563HM4D2.mjs} +6 -6
- package/dist/cli/{chunk-XSOLA2ED.mjs → chunk-5DU7RXDW.mjs} +4 -4
- package/dist/cli/{chunk-OWH7SSBO.mjs → chunk-5MYXW6M6.mjs} +2 -2
- package/dist/cli/{chunk-3BZ74K27.js → chunk-5N2HFB3G.js} +16 -16
- package/dist/cli/{chunk-2YOM5J3G.js → chunk-63DHG7BM.js} +26 -26
- package/dist/cli/{chunk-P7GOQTUN.js → chunk-6AL2VF3E.js} +14 -14
- package/dist/cli/{chunk-QBZECLNG.mjs → chunk-7BF4R26M.mjs} +3 -3
- package/dist/cli/{chunk-JRHMPZJX.js → chunk-7VQKU6MS.js} +7 -7
- package/dist/cli/{chunk-3C6VBHNW.mjs → chunk-7VT7RMZ2.mjs} +2 -2
- package/dist/cli/{chunk-M37I4A2Z.js → chunk-ASBWPRBN.js} +16 -16
- package/dist/cli/{chunk-3ZNPIJX6.js → chunk-B2T7PBS6.js} +41 -41
- package/dist/cli/{chunk-NC2FIUPX.mjs → chunk-B2U3LVSO.mjs} +1 -1
- package/dist/cli/{chunk-RNZQ7RDW.mjs → chunk-B6Q6BHSY.mjs} +2 -2
- package/dist/cli/{chunk-IZZ7FFWP.js → chunk-BPGFNVH2.js} +44 -44
- package/dist/cli/{chunk-2PYFXXYA.mjs → chunk-CLV4T5FN.mjs} +2 -2
- package/dist/cli/{chunk-JEB6BNIU.mjs → chunk-DEPBCRKG.mjs} +15 -4
- package/dist/cli/{chunk-DZ7JCRAL.mjs → chunk-DMF56C6D.mjs} +2 -2
- package/dist/cli/{chunk-RWXHMG6F.js → chunk-EEQ2QQOH.js} +21 -10
- package/dist/cli/{chunk-UDH3YMBI.mjs → chunk-EJ57CA2L.mjs} +1 -1
- package/dist/cli/{chunk-JYNHHO3J.js → chunk-F6IXWFPF.js} +6 -6
- package/dist/cli/{chunk-DWV7KM6H.mjs → chunk-FFPLCSTZ.mjs} +10 -10
- package/dist/cli/{chunk-VXNL4HLE.mjs → chunk-FND6GZZ4.mjs} +5 -5
- package/dist/cli/{chunk-D73YB5NQ.js → chunk-HC27PYJM.js} +2 -2
- package/dist/cli/{chunk-FRT5MFLF.mjs → chunk-HOKOJGQW.mjs} +1 -1
- package/dist/cli/{chunk-AYNO4VFW.js → chunk-JNECQ5QF.js} +11 -11
- package/dist/cli/chunk-JVEU6MXD.mjs +77 -0
- package/dist/cli/{chunk-ZLIAUR2E.js → chunk-JY73USD7.js} +2 -2
- package/dist/cli/{chunk-K4RME7AV.mjs → chunk-KXSOZYCS.mjs} +1 -1
- package/dist/cli/{chunk-ESVK4Z7S.js → chunk-LF3FF2B2.js} +1 -1
- package/dist/cli/{chunk-63BGKU3A.js → chunk-N7FV7OM3.js} +96 -96
- package/dist/cli/{chunk-Q4I5YKN4.mjs → chunk-OEG6VCK4.mjs} +1 -1
- package/dist/cli/{chunk-2LY42EZJ.mjs → chunk-PQ56GE55.mjs} +1 -1
- package/dist/cli/{chunk-GRGZKXLL.mjs → chunk-Q5EJO4TE.mjs} +5 -5
- package/dist/cli/{chunk-N5HRBS4K.js → chunk-QRQBKLOM.js} +3 -3
- package/dist/cli/{chunk-4DAR2GYV.mjs → chunk-RHKFNEV2.mjs} +2 -2
- package/dist/cli/{chunk-C6TP4DR3.mjs → chunk-UV524JZ5.mjs} +1 -1
- package/dist/cli/{chunk-KSQO32L5.mjs → chunk-V6DLYRSO.mjs} +1 -1
- package/dist/cli/{chunk-J3LJ37WD.js → chunk-VPJSQMWQ.js} +3 -3
- package/dist/cli/{chunk-3XBI4KZM.mjs → chunk-WAOLTP6R.mjs} +2 -2
- package/dist/cli/{chunk-JXYVBF5L.mjs → chunk-WC5754QJ.mjs} +5 -5
- package/dist/cli/{chunk-RUD77W2Y.js → chunk-XJZU7KO4.js} +5 -5
- package/dist/cli/{chunk-GDHLL5EQ.js → chunk-XK3AJFYQ.js} +35 -10
- package/dist/cli/{chunk-JUYW6TSU.js → chunk-XL4FFVWL.js} +7 -7
- package/dist/cli/{chunk-ZL2ME3UT.js → chunk-XRLE2FPE.js} +6 -6
- package/dist/cli/{chunk-R4S2AK3Q.js → chunk-YDALHHUC.js} +53 -53
- package/dist/cli/{chunk-IF242BIJ.mjs → chunk-YYUVOUEH.mjs} +5 -5
- package/dist/cli/{chunk-TVADI7K5.js → chunk-ZCYV6MZH.js} +5 -5
- package/dist/cli/{chunk-AFSYNOG4.mjs → chunk-ZRACZKEE.mjs} +35 -10
- package/dist/cli/command-docs.js +2 -2
- package/dist/cli/command-docs.mjs +1 -1
- package/dist/cli/{csv-CMJSMC2I.mjs → csv-MTFVEDPU.mjs} +4 -4
- package/dist/cli/{csv-DPDO6BU6.js → csv-UXFQZLZM.js} +13 -13
- package/dist/cli/{db-SL3EFN6V.mjs → db-3WPUYCCI.mjs} +6 -6
- package/dist/cli/{db-PPPKNTT5.js → db-RGWT6B7K.js} +27 -27
- package/dist/cli/describe-LNCLA2LA.js +50 -0
- package/dist/cli/{describe-XLN33FJX.mjs → describe-XJY5654F.mjs} +18 -18
- package/dist/cli/{executions-6YDTV2J6.js → executions-IWTALFNB.js} +8 -8
- package/dist/cli/{executions-O6Z5B5NY.mjs → executions-PDE4V5YH.mjs} +6 -6
- package/dist/cli/{feedback-DP7LPWAD.mjs → feedback-BMOVTPC4.mjs} +11 -7
- package/dist/cli/{feedback-BZ434BN4.js → feedback-I72P4XZS.js} +15 -11
- package/dist/cli/{git-MI7E5WGL.mjs → git-QJG3EF4P.mjs} +5 -5
- package/dist/cli/git-QWH7SPGF.js +25 -0
- package/dist/cli/index.js +173 -156
- package/dist/cli/index.mjs +76 -59
- package/dist/cli/{legacy-noops-65WNPQVZ.js → legacy-noops-5P75CQC7.js} +9 -8
- package/dist/cli/{legacy-noops-6VYXF2MG.mjs → legacy-noops-MZ45GDMK.mjs} +6 -5
- package/dist/cli/{monitors-BYUCTVSC.js → monitors-5PHQZDZM.js} +100 -100
- package/dist/cli/{monitors-Y7I5ZVCN.mjs → monitors-VIOBUG2X.mjs} +7 -7
- package/dist/cli/{org-F2ASWTFY.js → org-B5LDVP2P.js} +72 -72
- package/dist/cli/{org-IW3YD6JZ.mjs → org-D5RTFJNY.mjs} +6 -6
- package/dist/cli/{pages-X6HLRQNV.js → pages-BUJYG3JL.js} +18 -18
- package/dist/cli/{pages-H2CXNIDB.mjs → pages-XWZL3YV2.mjs} +6 -6
- package/dist/cli/{play-LLEEDXRX.mjs → play-OSXLGCLZ.mjs} +93 -54
- package/dist/cli/{play-H2EM7DTI.js → play-SEC3EE7H.js} +468 -429
- package/dist/cli/{providers-BZR5JONN.mjs → providers-ENSURIW6.mjs} +6 -6
- package/dist/cli/{providers-6R2SPOEV.js → providers-RQPUASLI.js} +9 -9
- package/dist/cli/{quickstart-KVES7R6D.mjs → quickstart-HJTK6XWI.mjs} +4 -4
- package/dist/cli/{quickstart-PW7ONQUH.js → quickstart-XDTU4MAT.js} +6 -6
- package/dist/cli/{run-HVUQROBE.js → run-GX2SU5AT.js} +41 -41
- package/dist/cli/{run-RDI3Q6GO.mjs → run-ZMWSQAR2.mjs} +23 -23
- package/dist/cli/search-7WPABWYO.js +33 -0
- package/dist/cli/{search-3TJ24CUF.mjs → search-DZHZBHWT.mjs} +8 -8
- package/dist/cli/{search-output-JHT553SL.js → search-output-3JVZERNV.js} +6 -6
- package/dist/cli/{search-output-Y57OBQXX.mjs → search-output-MNHAR754.mjs} +4 -4
- package/dist/cli/{secrets-OZK7GRD5.mjs → secrets-VALVNVXB.mjs} +6 -6
- package/dist/cli/{secrets-U5JHWAXU.js → secrets-WO2LMDQ2.js} +15 -15
- package/dist/cli/sessions-2IA2DGWO.js +18 -0
- package/dist/cli/{sessions-D6DSEQ2T.mjs → sessions-EPYCH3AY.mjs} +6 -5
- package/dist/cli/{settings-DLPEHYGS.js → settings-OSF4O5HM.js} +109 -82
- package/dist/cli/{settings-ITLSLT2R.mjs → settings-W2ABZUD4.mjs} +39 -12
- package/dist/cli/{setup-Y5ZYEC6U.js → setup-DCXNQG6R.js} +50 -50
- package/dist/cli/{setup-XTYLF2CF.mjs → setup-XI2ERSMQ.mjs} +10 -10
- package/dist/cli/skills-QMD2WARJ.js +37 -0
- package/dist/cli/{skills-C4WCAVII.mjs → skills-ZO4AH2YR.mjs} +8 -8
- package/dist/cli/tools-53E6GBQU.js +57 -0
- package/dist/cli/{tools-ZESAPVOW.mjs → tools-FTECXZYA.mjs} +17 -17
- package/dist/cli/update-PPPNR6J5.js +35 -0
- package/dist/cli/{update-4PCKVDCS.mjs → update-WPFZO2JE.mjs} +10 -10
- package/dist/cli/{workflow-42CL4TVR.mjs → workflow-7X75IP3D.mjs} +7 -7
- package/dist/cli/{workflow-XXKXMPTI.js → workflow-PKMU33LV.js} +17 -17
- package/dist/index.js +9 -9
- package/dist/index.mjs +6 -6
- package/dist/install-integrity.json +105 -102
- package/dist/release.d.mts +1 -1
- package/dist/release.d.ts +1 -1
- package/dist/release.js +2 -2
- package/dist/release.mjs +1 -1
- package/dist/server.js +5 -5
- package/dist/server.mjs +3 -3
- package/package.json +1 -1
- package/dist/cli/auth-LFU77QDI.js +0 -43
- package/dist/cli/describe-JKZ67X3E.js +0 -50
- package/dist/cli/git-U5N6CTML.js +0 -25
- package/dist/cli/search-NKEEGLY6.js +0 -33
- package/dist/cli/sessions-PNMYAJNB.js +0 -17
- package/dist/cli/skills-K6FVG3BX.js +0 -37
- package/dist/cli/tools-LSALTN7I.js +0 -57
- package/dist/cli/update-P5KGNFNL.js +0 -35
package/dist/bundling-sources/shared_libs/play-runtime/deployment/commands/runtime-topology.ts
CHANGED
|
@@ -30,6 +30,12 @@ import {
|
|
|
30
30
|
shouldCreateDetachedProcessGroup,
|
|
31
31
|
terminateChildProcessTree,
|
|
32
32
|
} from '../process-tree';
|
|
33
|
+
import {
|
|
34
|
+
classifyFlyCommandError,
|
|
35
|
+
classifyFlyCommandFailure,
|
|
36
|
+
FlyCommandError,
|
|
37
|
+
withFlyTransientRetry,
|
|
38
|
+
} from '../fly-transient-retry';
|
|
33
39
|
|
|
34
40
|
export enum TopologyOperation {
|
|
35
41
|
ReconcilePlatform = 'reconcile-platform',
|
|
@@ -109,6 +115,11 @@ export type RuntimeTopologyCommand = (input: {
|
|
|
109
115
|
args: string[];
|
|
110
116
|
environment: Record<string, string>;
|
|
111
117
|
description: string;
|
|
118
|
+
/**
|
|
119
|
+
* A flyctl command that converges when repeated (a staged secret write of
|
|
120
|
+
* the same values). Transient Fly API failures are retried.
|
|
121
|
+
*/
|
|
122
|
+
flyTransientRetry?: 'idempotent-write';
|
|
112
123
|
}) => void | Promise<void>;
|
|
113
124
|
|
|
114
125
|
/**
|
|
@@ -122,6 +133,7 @@ export type RuntimeTopologyParallelCommand = (input: {
|
|
|
122
133
|
args: string[];
|
|
123
134
|
environment: Record<string, string>;
|
|
124
135
|
description: string;
|
|
136
|
+
flyTransientRetry?: 'idempotent-write';
|
|
125
137
|
}) => Promise<void>;
|
|
126
138
|
|
|
127
139
|
export type RuntimeTopologySpawn = (
|
|
@@ -149,9 +161,13 @@ const activeRuntimeTopologyCommands = new Set<ActiveRuntimeTopologyCommand>();
|
|
|
149
161
|
const runtimeTopologyCancellationSignals: readonly RuntimeTopologyCancellationSignal[] =
|
|
150
162
|
['SIGINT', 'SIGTERM'];
|
|
151
163
|
|
|
164
|
+
/** Set once cancellation is requested so no transient retry starts after it. */
|
|
165
|
+
let runtimeTopologyCancellation: RuntimeTopologyCancellationSignal | undefined;
|
|
166
|
+
|
|
152
167
|
function cancelActiveRuntimeTopologyCommands(
|
|
153
168
|
signal: RuntimeTopologyCancellationSignal,
|
|
154
169
|
): number {
|
|
170
|
+
runtimeTopologyCancellation ??= signal;
|
|
155
171
|
for (const command of activeRuntimeTopologyCommands) command.cancel(signal);
|
|
156
172
|
return activeRuntimeTopologyCommands.size;
|
|
157
173
|
}
|
|
@@ -254,18 +270,61 @@ export function runRuntimeTopologyCommand(
|
|
|
254
270
|
}
|
|
255
271
|
}
|
|
256
272
|
|
|
273
|
+
/** Enough trailing output to classify a flyctl transport failure. */
|
|
274
|
+
const FLY_RETRY_OUTPUT_TAIL_CHARACTERS = 16_384;
|
|
275
|
+
|
|
257
276
|
export async function runRuntimeTopologyAsyncCommand(input: {
|
|
258
277
|
command: string;
|
|
259
278
|
args: string[];
|
|
260
279
|
environment: Record<string, string>;
|
|
261
280
|
description: string;
|
|
281
|
+
flyTransientRetry?: 'idempotent-write';
|
|
262
282
|
}): Promise<void> {
|
|
283
|
+
if (!input.flyTransientRetry || input.command !== 'flyctl') {
|
|
284
|
+
await runRuntimeTopologyAsyncAttempt(input);
|
|
285
|
+
return;
|
|
286
|
+
}
|
|
287
|
+
const operation = input.flyTransientRetry;
|
|
288
|
+
await withFlyTransientRetry(
|
|
289
|
+
async (attempt) => {
|
|
290
|
+
if (attempt > 1 && runtimeTopologyCancellation) {
|
|
291
|
+
throw new Error(
|
|
292
|
+
`${input.description} was not retried: cancellation requested by ${runtimeTopologyCancellation}.`,
|
|
293
|
+
);
|
|
294
|
+
}
|
|
295
|
+
await runRuntimeTopologyAsyncAttempt({ ...input, operation });
|
|
296
|
+
},
|
|
297
|
+
classifyFlyCommandError,
|
|
298
|
+
{ label: input.description },
|
|
299
|
+
);
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
/**
|
|
303
|
+
* One child process. With `operation` set, its output is forwarded live and a
|
|
304
|
+
* bounded tail is kept to classify a failure as a transient Fly API error.
|
|
305
|
+
*/
|
|
306
|
+
async function runRuntimeTopologyAsyncAttempt(input: {
|
|
307
|
+
command: string;
|
|
308
|
+
args: string[];
|
|
309
|
+
environment: Record<string, string>;
|
|
310
|
+
description: string;
|
|
311
|
+
operation?: 'idempotent-write';
|
|
312
|
+
}): Promise<void> {
|
|
313
|
+
let outputTail = '';
|
|
314
|
+
const capture = (chunk: Buffer, sink: NodeJS.WriteStream): void => {
|
|
315
|
+
sink.write(chunk);
|
|
316
|
+
outputTail = `${outputTail}${chunk.toString('utf8')}`.slice(
|
|
317
|
+
-FLY_RETRY_OUTPUT_TAIL_CHARACTERS,
|
|
318
|
+
);
|
|
319
|
+
};
|
|
263
320
|
await new Promise<void>((resolve, reject) => {
|
|
264
321
|
const child = spawn(input.command, input.args, {
|
|
265
322
|
env: { ...process.env, ...input.environment },
|
|
266
|
-
stdio: 'inherit',
|
|
323
|
+
stdio: input.operation ? ['ignore', 'pipe', 'pipe'] : 'inherit',
|
|
267
324
|
detached: shouldCreateDetachedProcessGroup(),
|
|
268
325
|
});
|
|
326
|
+
child.stdout?.on('data', (chunk: Buffer) => capture(chunk, process.stdout));
|
|
327
|
+
child.stderr?.on('data', (chunk: Buffer) => capture(chunk, process.stderr));
|
|
269
328
|
const activeCommand: ActiveRuntimeTopologyCommand = {
|
|
270
329
|
cancel: (signal) => {
|
|
271
330
|
if (child.exitCode === null && child.signalCode === null) {
|
|
@@ -301,12 +360,24 @@ export async function runRuntimeTopologyAsyncCommand(input: {
|
|
|
301
360
|
resolve();
|
|
302
361
|
return;
|
|
303
362
|
}
|
|
363
|
+
const message = signal
|
|
364
|
+
? `${input.description} was terminated by ${signal}.`
|
|
365
|
+
: `${input.description} failed with exit code ${status ?? '<unknown>'}.`;
|
|
366
|
+
if (!input.operation) {
|
|
367
|
+
reject(new Error(message));
|
|
368
|
+
return;
|
|
369
|
+
}
|
|
304
370
|
reject(
|
|
305
|
-
new
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
371
|
+
new FlyCommandError({
|
|
372
|
+
message,
|
|
373
|
+
status,
|
|
374
|
+
classification: classifyFlyCommandFailure({
|
|
375
|
+
status,
|
|
376
|
+
signal,
|
|
377
|
+
output: outputTail,
|
|
378
|
+
operation: input.operation,
|
|
379
|
+
}),
|
|
380
|
+
}),
|
|
310
381
|
);
|
|
311
382
|
});
|
|
312
383
|
});
|
|
@@ -376,6 +447,8 @@ async function stageSecrets(input: {
|
|
|
376
447
|
],
|
|
377
448
|
environment: input.environment,
|
|
378
449
|
description: `Stage secrets for ${app}`,
|
|
450
|
+
// Staging the same values again converges; Fly resets are transient.
|
|
451
|
+
flyTransientRetry: 'idempotent-write' as const,
|
|
379
452
|
}));
|
|
380
453
|
await runIndependentTopologyCommands(input, commands);
|
|
381
454
|
}
|
|
@@ -38,6 +38,15 @@ import {
|
|
|
38
38
|
runtimeMachineImageMatches,
|
|
39
39
|
type FlyMachineImageRef,
|
|
40
40
|
} from './fly-registry';
|
|
41
|
+
import {
|
|
42
|
+
classifyFlyRequestError,
|
|
43
|
+
FlyPermanentHttpError,
|
|
44
|
+
FlyRequestTimeoutError,
|
|
45
|
+
FlyTransientHttpError,
|
|
46
|
+
isTransientFlyHttpStatus,
|
|
47
|
+
parseRetryAfterMs,
|
|
48
|
+
withFlyTransientRetry,
|
|
49
|
+
} from './fly-transient-retry';
|
|
41
50
|
|
|
42
51
|
export const FLY_MACHINES_API_BASE = 'https://api.machines.dev/v1';
|
|
43
52
|
export const FLY_REGISTRY_HOST = 'registry.fly.io';
|
|
@@ -139,6 +148,34 @@ export const FLY_READ_RATE_LIMIT_RETRY_DELAYS_MS = [
|
|
|
139
148
|
/** A provider request may not hold the production release fence forever. */
|
|
140
149
|
export const FLY_MACHINES_REQUEST_TIMEOUT_MS = 30_000;
|
|
141
150
|
|
|
151
|
+
/**
|
|
152
|
+
* Machines API requests that converge when repeated, so a transient failure
|
|
153
|
+
* (5xx, 429, timeout, connection reset) may be retried. Excluded on purpose:
|
|
154
|
+
* `POST /machines` (create) and `POST /machines/{id}` (config update) each
|
|
155
|
+
* produce a new effect, `POST .../lease` fails once the first call won, and
|
|
156
|
+
* `POST /secrets` advances the secrets version. Their callers re-read state.
|
|
157
|
+
*/
|
|
158
|
+
export function isIdempotentFlyMachinesRequest(
|
|
159
|
+
method: string,
|
|
160
|
+
path: string,
|
|
161
|
+
): boolean {
|
|
162
|
+
if (method === 'GET' || method === 'DELETE') return true;
|
|
163
|
+
return (
|
|
164
|
+
method === 'POST' &&
|
|
165
|
+
/^\/machines\/[^/]+\/(?:cordon|uncordon|start|stop|metadata\/[^/]+)$/.test(
|
|
166
|
+
path,
|
|
167
|
+
)
|
|
168
|
+
);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
export type FlyMachinesTransientRetryOptions = Readonly<{
|
|
172
|
+
attempts?: number;
|
|
173
|
+
baseDelayMs?: number;
|
|
174
|
+
deadlineMs?: number;
|
|
175
|
+
now?: () => number;
|
|
176
|
+
random?: () => number;
|
|
177
|
+
}>;
|
|
178
|
+
|
|
142
179
|
export type FetchLike = (
|
|
143
180
|
input: string,
|
|
144
181
|
init?: {
|
|
@@ -764,6 +801,12 @@ export class FlyMachinesClient {
|
|
|
764
801
|
wait?: (ms: number) => Promise<void>;
|
|
765
802
|
retryDelaysMs?: readonly number[];
|
|
766
803
|
requestTimeoutMs?: number;
|
|
804
|
+
/**
|
|
805
|
+
* Opt-in bounded retry of transient failures (5xx, 429, timeouts,
|
|
806
|
+
* connection resets) for idempotent requests only. Release and recovery
|
|
807
|
+
* CLIs enable it; long-running controllers keep their own cadence.
|
|
808
|
+
*/
|
|
809
|
+
transientRetry?: true | FlyMachinesTransientRetryOptions;
|
|
767
810
|
/** Preview CLI diagnostics only; no provider arguments or bodies. */
|
|
768
811
|
phaseTiming?: Readonly<{
|
|
769
812
|
now?: () => number;
|
|
@@ -838,6 +881,28 @@ export class FlyMachinesClient {
|
|
|
838
881
|
path: string,
|
|
839
882
|
body?: unknown,
|
|
840
883
|
leaseNonce?: string,
|
|
884
|
+
): Promise<unknown> {
|
|
885
|
+
const transientRetry = this.rateLimitOptions.transientRetry;
|
|
886
|
+
if (!transientRetry || !isIdempotentFlyMachinesRequest(method, path)) {
|
|
887
|
+
return await this.requestOnce(method, path, body, leaseNonce);
|
|
888
|
+
}
|
|
889
|
+
const policy = transientRetry === true ? {} : transientRetry;
|
|
890
|
+
return await withFlyTransientRetry(
|
|
891
|
+
() => this.requestOnce(method, path, body, leaseNonce),
|
|
892
|
+
classifyFlyRequestError,
|
|
893
|
+
{
|
|
894
|
+
...policy,
|
|
895
|
+
label: `Fly Machines API ${method} /apps/${this.app}${path}`,
|
|
896
|
+
sleep: this.rateLimitOptions.wait ?? sleep,
|
|
897
|
+
},
|
|
898
|
+
);
|
|
899
|
+
}
|
|
900
|
+
|
|
901
|
+
private async requestOnce(
|
|
902
|
+
method: string,
|
|
903
|
+
path: string,
|
|
904
|
+
body?: unknown,
|
|
905
|
+
leaseNonce?: string,
|
|
841
906
|
): Promise<unknown> {
|
|
842
907
|
const retryDelaysMs =
|
|
843
908
|
this.rateLimitOptions.retryDelaysMs ??
|
|
@@ -865,7 +930,7 @@ export class FlyMachinesClient {
|
|
|
865
930
|
);
|
|
866
931
|
} catch (error) {
|
|
867
932
|
if (signal.aborted) {
|
|
868
|
-
throw new
|
|
933
|
+
throw new FlyRequestTimeoutError(
|
|
869
934
|
`Fly Machines API ${method} ${path} timed out after ${requestTimeoutMs}ms.`,
|
|
870
935
|
{ cause: error },
|
|
871
936
|
);
|
|
@@ -897,9 +962,15 @@ export class FlyMachinesClient {
|
|
|
897
962
|
}
|
|
898
963
|
if (!response.ok) {
|
|
899
964
|
const detail = await response.text().catch(() => '');
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
965
|
+
const message = `Fly Machines API ${method} ${path} failed: ${response.status} ${detail}`;
|
|
966
|
+
if (isTransientFlyHttpStatus(response.status)) {
|
|
967
|
+
throw new FlyTransientHttpError(
|
|
968
|
+
message,
|
|
969
|
+
response.status,
|
|
970
|
+
parseRetryAfterMs(response.headers?.get('retry-after'), Date.now()),
|
|
971
|
+
);
|
|
972
|
+
}
|
|
973
|
+
throw new FlyPermanentHttpError(message, response.status);
|
|
903
974
|
}
|
|
904
975
|
if (response.status === 204) return null;
|
|
905
976
|
return await readJsonResponseBody({
|
|
@@ -1719,7 +1790,7 @@ async function cmdBoot(flags: Record<string, string | boolean>): Promise<void> {
|
|
|
1719
1790
|
app,
|
|
1720
1791
|
requireFlyToken(),
|
|
1721
1792
|
globalThis.fetch as FetchLike,
|
|
1722
|
-
{ phaseTiming: previewMachinePhaseTiming(flags) },
|
|
1793
|
+
{ phaseTiming: previewMachinePhaseTiming(flags), transientRetry: true },
|
|
1723
1794
|
);
|
|
1724
1795
|
await bootLane({
|
|
1725
1796
|
client,
|
|
@@ -1764,7 +1835,7 @@ async function cmdReplace(
|
|
|
1764
1835
|
app,
|
|
1765
1836
|
requireFlyToken(),
|
|
1766
1837
|
globalThis.fetch as FetchLike,
|
|
1767
|
-
{ phaseTiming: previewMachinePhaseTiming(flags) },
|
|
1838
|
+
{ phaseTiming: previewMachinePhaseTiming(flags), transientRetry: true },
|
|
1768
1839
|
);
|
|
1769
1840
|
await replaceLane({
|
|
1770
1841
|
client,
|
|
@@ -1810,6 +1881,7 @@ async function cmdList(flags: Record<string, string | boolean>): Promise<void> {
|
|
|
1810
1881
|
app,
|
|
1811
1882
|
requireFlyToken(),
|
|
1812
1883
|
globalThis.fetch as FetchLike,
|
|
1884
|
+
{ transientRetry: true },
|
|
1813
1885
|
);
|
|
1814
1886
|
const release = typeof flags.release === 'string' ? flags.release : null;
|
|
1815
1887
|
const machines = release
|
|
@@ -1933,6 +2005,7 @@ async function cmdDrain(
|
|
|
1933
2005
|
app,
|
|
1934
2006
|
requireFlyToken(),
|
|
1935
2007
|
globalThis.fetch as FetchLike,
|
|
2008
|
+
{ transientRetry: true },
|
|
1936
2009
|
);
|
|
1937
2010
|
await drainLane({
|
|
1938
2011
|
client,
|
|
@@ -2392,6 +2465,7 @@ async function cmdRetire(
|
|
|
2392
2465
|
app,
|
|
2393
2466
|
requireFlyToken(),
|
|
2394
2467
|
globalThis.fetch as FetchLike,
|
|
2468
|
+
{ transientRetry: true },
|
|
2395
2469
|
);
|
|
2396
2470
|
await retireLane({
|
|
2397
2471
|
client,
|