devflare 1.0.0-next.66 → 1.0.0-next.68
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/_chunks/{cli-CWKMIIcG.js → cli-DXnofibT.js} +1 -1
- package/dist/_chunks/{workspace-CaTsTpDI.js → workspace-DE60No0K.js} +14 -3
- package/dist/cli/index.js +1 -1
- package/dist/dev-server/workspace/merge-config.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/sveltekit/index.js +40 -1
- package/dist/sveltekit/platform.d.ts +22 -0
- package/dist/sveltekit/platform.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1144,7 +1144,7 @@ async function runDev(parsed, logger, options) {
|
|
|
1144
1144
|
return runDevCommand(parsed, logger, options);
|
|
1145
1145
|
}
|
|
1146
1146
|
async function runWorkspace(parsed, logger, options) {
|
|
1147
|
-
const { runWorkspaceCommand } = await import("./workspace-
|
|
1147
|
+
const { runWorkspaceCommand } = await import("./workspace-DE60No0K.js");
|
|
1148
1148
|
return runWorkspaceCommand(parsed, logger, options);
|
|
1149
1149
|
}
|
|
1150
1150
|
async function runBuild(parsed, logger, options) {
|
|
@@ -13,12 +13,17 @@ import { n as bundleWorkflowEntrypointScript } from "./r2-presign-runtime-C75FkL
|
|
|
13
13
|
import { dirname, resolve } from "pathe";
|
|
14
14
|
import { createConsola } from "consola";
|
|
15
15
|
//#region src/dev-server/workspace/merge-config.ts
|
|
16
|
+
const NAMESPACE_SEPARATOR = "-";
|
|
17
|
+
/** Join an app namespace to one of its worker names for the merged instance. */
|
|
18
|
+
function namespacedWorkerName(appName, workerName) {
|
|
19
|
+
return `${appName}${NAMESPACE_SEPARATOR}${workerName}`;
|
|
20
|
+
}
|
|
16
21
|
/**
|
|
17
22
|
* Prefix `name` with `${appName}/` — but only when it is one of this app's own
|
|
18
23
|
* worker names. External/cross-app targets are left untouched.
|
|
19
24
|
*/
|
|
20
25
|
function namespaceIfLocal(name, appName, localNames) {
|
|
21
|
-
return localNames.has(name) ?
|
|
26
|
+
return localNames.has(name) ? namespacedWorkerName(appName, name) : name;
|
|
22
27
|
}
|
|
23
28
|
/** Rewrite an intra-app worker reference on a service-binding value (object or string form). */
|
|
24
29
|
function rewriteServiceBindingTarget(value, appName, localNames) {
|
|
@@ -47,9 +52,9 @@ function namespaceAppWorkers(appName, workers, options) {
|
|
|
47
52
|
for (const value of Object.values(worker.durableObjects)) if (value && typeof value === "object" && typeof value.scriptName === "string") value.scriptName = namespaceIfLocal(value.scriptName, appName, localNames);
|
|
48
53
|
}
|
|
49
54
|
if (worker.outboundService !== void 0) worker.outboundService = rewriteServiceBindingTarget(worker.outboundService, appName, localNames);
|
|
50
|
-
worker.name =
|
|
55
|
+
worker.name = namespacedWorkerName(appName, String(worker.name));
|
|
51
56
|
}
|
|
52
|
-
const gatewayWorkerName =
|
|
57
|
+
const gatewayWorkerName = namespacedWorkerName(appName, "gateway");
|
|
53
58
|
const gatewayWorker = workers.find((worker) => worker.name === gatewayWorkerName) ?? workers[0];
|
|
54
59
|
gatewayWorker.unsafeDirectSockets = [{
|
|
55
60
|
host: options.host,
|
|
@@ -109,6 +114,12 @@ function buildMergedWorkspaceConfig(input) {
|
|
|
109
114
|
port: app.directSocketPort
|
|
110
115
|
});
|
|
111
116
|
}
|
|
117
|
+
const seenWorkerNames = /* @__PURE__ */ new Set();
|
|
118
|
+
for (const worker of mergedWorkers) {
|
|
119
|
+
const workerName = String(worker.name);
|
|
120
|
+
if (seenWorkerNames.has(workerName)) throw new Error(`Workspace produced two workers named "${workerName}" after namespacing. Rename one of the conflicting apps so their namespaced worker names stay distinct.`);
|
|
121
|
+
seenWorkerNames.add(workerName);
|
|
122
|
+
}
|
|
112
123
|
const persistPaths = resolveWorkspacePersistPaths(input.persist, input.persistDir);
|
|
113
124
|
return {
|
|
114
125
|
config: {
|
package/dist/cli/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as runCli, t as parseArgs } from "../_chunks/cli-
|
|
1
|
+
import { n as runCli, t as parseArgs } from "../_chunks/cli-DXnofibT.js";
|
|
2
2
|
export { parseArgs, runCli };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"merge-config.d.ts","sourceRoot":"","sources":["../../../src/dev-server/workspace/merge-config.ts"],"names":[],"mappings":"AAiBA,+EAA+E;AAC/E,KAAK,eAAe,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;
|
|
1
|
+
{"version":3,"file":"merge-config.d.ts","sourceRoot":"","sources":["../../../src/dev-server/workspace/merge-config.ts"],"names":[],"mappings":"AAiBA,+EAA+E;AAC/E,KAAK,eAAe,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;AAsB1C,qDAAqD;AACrD,MAAM,WAAW,mBAAmB;IACnC,6DAA6D;IAC7D,OAAO,EAAE,MAAM,CAAA;IACf,oFAAoF;IACpF,OAAO,EAAE,eAAe,EAAE,CAAA;IAC1B,mEAAmE;IACnE,gBAAgB,EAAE,MAAM,CAAA;CACxB;AAED,sFAAsF;AACtF,MAAM,WAAW,qBAAqB;IACrC,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,qBAAqB,CAAC,EAAE,MAAM,CAAA;IAC9B,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,aAAa,CAAC,EAAE,MAAM,CAAA;CACtB;AAyBD;;;;;;;;;;;GAWG;AACH,wBAAgB,mBAAmB,CAClC,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,eAAe,EAAE,EAC1B,OAAO,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,gBAAgB,EAAE,MAAM,CAAA;CAAE,GACjD;IAAE,OAAO,EAAE,eAAe,EAAE,CAAC;IAAC,iBAAiB,EAAE,MAAM,CAAA;CAAE,CAwD3D;AAED,sFAAsF;AACtF,wBAAgB,4BAA4B,CAC3C,OAAO,EAAE,OAAO,EAChB,UAAU,EAAE,MAAM,GAChB,qBAAqB,GAAG,SAAS,CAcnC;AAED,oDAAoD;AACpD,MAAM,WAAW,+BAA+B;IAC/C,sEAAsE;IACtE,IAAI,EAAE,mBAAmB,EAAE,CAAA;IAC3B,2CAA2C;IAC3C,IAAI,EAAE,MAAM,CAAA;IACZ,0CAA0C;IAC1C,OAAO,EAAE,OAAO,CAAA;IAChB,yEAAyE;IACzE,UAAU,EAAE,MAAM,CAAA;IAClB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;CAClB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,+BAA+B,GAAG;IACnF,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAC3B,aAAa,EAAE,KAAK,CAAC;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,iBAAiB,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CAClF,CA4DA"}
|
package/dist/index.js
CHANGED
|
@@ -5,6 +5,6 @@ import { a as ConfigResourceResolutionError, d as configSchema, n as ConfigValid
|
|
|
5
5
|
import { n as compileConfig, s as stringifyConfig } from "./_chunks/compiler-UxXQgEPq.js";
|
|
6
6
|
import { t as workerName } from "./_chunks/workerName-kEXwmV2m.js";
|
|
7
7
|
import { n as getDurableObjectOptions, t as durableObject } from "./_chunks/decorators-eXNZ1S0N.js";
|
|
8
|
-
import { n as runCli, t as parseArgs } from "./_chunks/cli-
|
|
8
|
+
import { n as runCli, t as parseArgs } from "./_chunks/cli-DXnofibT.js";
|
|
9
9
|
import { i as vars, r as env } from "./_chunks/env-DyL6JOXI.js";
|
|
10
10
|
export { ConfigNotFoundError, ConfigResourceResolutionError, ConfigValidationError, compileConfig, configSchema, defineConfig as default, defineConfig, defineWorkspace, durableObject, env, getDurableObjectOptions, loadConfig, loadResolvedConfig, parseArgs, preview, ref, runCli, stringifyConfig, vars, workerName };
|
package/dist/sveltekit/index.js
CHANGED
|
@@ -88,6 +88,45 @@ function createDevExecutionContext(pendingErrors) {
|
|
|
88
88
|
};
|
|
89
89
|
}
|
|
90
90
|
/**
|
|
91
|
+
* Total budget for riding out a transient bridge outage while (re)connecting for a request. An HMR worker
|
|
92
|
+
* reload or a brief coordinator restart drops the bridge socket for well under a second; retrying within this
|
|
93
|
+
* window keeps the request's bindings available instead of failing it. Kept modest so a bridge that is
|
|
94
|
+
* genuinely down (devflare not running) still surfaces the error promptly rather than hanging every request.
|
|
95
|
+
*/
|
|
96
|
+
const BRIDGE_CONNECT_MAX_WAIT_MS = 3e3;
|
|
97
|
+
/** Delay between bridge (re)connect attempts within {@link BRIDGE_CONNECT_MAX_WAIT_MS}. */
|
|
98
|
+
const BRIDGE_CONNECT_RETRY_DELAY_MS = 150;
|
|
99
|
+
/**
|
|
100
|
+
* Connect to the bridge, riding out a TRANSIENT outage with a bounded retry.
|
|
101
|
+
*
|
|
102
|
+
* The bridge socket drops for a fraction of a second whenever the dev runtime reloads a worker (HMR /
|
|
103
|
+
* config change) or the coordinator briefly restarts (e.g. after a worker threw). A single per-request
|
|
104
|
+
* `connect()` attempt rejects the instant the socket is refused, which the SvelteKit handle turns into
|
|
105
|
+
* "dropped every binding for this request" — so an unrelated route 500s with a missing D1/KV/R2 binding
|
|
106
|
+
* mid-reload. Retrying for a short window instead lets the reconnect land and the request proceed. The LAST
|
|
107
|
+
* error is rethrown only once the budget is spent (the bridge really is down), so a genuine
|
|
108
|
+
* misconfiguration still fails fast rather than hanging.
|
|
109
|
+
*
|
|
110
|
+
* Exported for unit testing; `sleep`/`now` are injectable so the retry schedule is asserted without real time.
|
|
111
|
+
*
|
|
112
|
+
* @param connect - the bridge client's `connect()`; a fresh attempt each call (the client dedups in-flight ones).
|
|
113
|
+
* @param options - `maxWaitMs` total budget, `retryDelayMs` between attempts, and injectable `sleep`/`now` for tests.
|
|
114
|
+
*/
|
|
115
|
+
async function connectBridgeWithRetry(connect, options = {}) {
|
|
116
|
+
const maxWaitMs = options.maxWaitMs ?? BRIDGE_CONNECT_MAX_WAIT_MS;
|
|
117
|
+
const retryDelayMs = options.retryDelayMs ?? BRIDGE_CONNECT_RETRY_DELAY_MS;
|
|
118
|
+
const sleep = options.sleep ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
|
|
119
|
+
const now = options.now ?? Date.now;
|
|
120
|
+
const deadline = now() + maxWaitMs;
|
|
121
|
+
for (;;) try {
|
|
122
|
+
await connect();
|
|
123
|
+
return;
|
|
124
|
+
} catch (error) {
|
|
125
|
+
if (now() + retryDelayMs >= deadline) throw error;
|
|
126
|
+
await sleep(retryDelayMs);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
91
130
|
* Create a platform object that routes bindings through the bridge
|
|
92
131
|
*
|
|
93
132
|
* Use this in dev mode to get access to Miniflare bindings via WebSocket RPC.
|
|
@@ -119,7 +158,7 @@ async function createDevflarePlatform(options = {}) {
|
|
|
119
158
|
const cacheKey = getPlatformCacheKey(bridgeUrl, hints);
|
|
120
159
|
if (shouldUseCachedPlatform(localBindings) && platformCache?.key === cacheKey) return platformCache.platform;
|
|
121
160
|
const client = getClient({ url: bridgeUrl });
|
|
122
|
-
await client.connect();
|
|
161
|
+
await connectBridgeWithRetry(() => client.connect());
|
|
123
162
|
const env = overlayLocalBindings(createEnvProxy({
|
|
124
163
|
client,
|
|
125
164
|
hints,
|
|
@@ -36,6 +36,28 @@ export interface DevflarePlatformOptions {
|
|
|
36
36
|
* Returns a snapshot of the pending errors and clears the buffer.
|
|
37
37
|
*/
|
|
38
38
|
export declare function drainWaitUntilErrors(platform: Platform): unknown[];
|
|
39
|
+
/**
|
|
40
|
+
* Connect to the bridge, riding out a TRANSIENT outage with a bounded retry.
|
|
41
|
+
*
|
|
42
|
+
* The bridge socket drops for a fraction of a second whenever the dev runtime reloads a worker (HMR /
|
|
43
|
+
* config change) or the coordinator briefly restarts (e.g. after a worker threw). A single per-request
|
|
44
|
+
* `connect()` attempt rejects the instant the socket is refused, which the SvelteKit handle turns into
|
|
45
|
+
* "dropped every binding for this request" — so an unrelated route 500s with a missing D1/KV/R2 binding
|
|
46
|
+
* mid-reload. Retrying for a short window instead lets the reconnect land and the request proceed. The LAST
|
|
47
|
+
* error is rethrown only once the budget is spent (the bridge really is down), so a genuine
|
|
48
|
+
* misconfiguration still fails fast rather than hanging.
|
|
49
|
+
*
|
|
50
|
+
* Exported for unit testing; `sleep`/`now` are injectable so the retry schedule is asserted without real time.
|
|
51
|
+
*
|
|
52
|
+
* @param connect - the bridge client's `connect()`; a fresh attempt each call (the client dedups in-flight ones).
|
|
53
|
+
* @param options - `maxWaitMs` total budget, `retryDelayMs` between attempts, and injectable `sleep`/`now` for tests.
|
|
54
|
+
*/
|
|
55
|
+
export declare function connectBridgeWithRetry(connect: () => Promise<void>, options?: {
|
|
56
|
+
maxWaitMs?: number;
|
|
57
|
+
retryDelayMs?: number;
|
|
58
|
+
sleep?: (ms: number) => Promise<void>;
|
|
59
|
+
now?: () => number;
|
|
60
|
+
}): Promise<void>;
|
|
39
61
|
/**
|
|
40
62
|
* Create a platform object that routes bindings through the bridge
|
|
41
63
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"platform.d.ts","sourceRoot":"","sources":["../../src/sveltekit/platform.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,KAAK,YAAY,EAA8C,MAAM,WAAW,CAAA;AAUzF;;GAEG;AACH,MAAM,WAAW,QAAQ;IACxB,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC5B,OAAO,EAAE,gBAAgB,CAAA;IACzB,MAAM,EAAE,YAAY,CAAA;IACpB,EAAE,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CA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