@livestore/utils-dev 0.0.0-snapshot-785d927ad644da4e856ea5d73244571f23ede77e → 0.0.0-snapshot-9e97cae75eb5411b3aa53cfd87dcb082a536fc61
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WranglerDevServer.d.ts","sourceRoot":"","sources":["../../src/wrangler/WranglerDevServer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"WranglerDevServer.d.ts","sourceRoot":"","sources":["../../src/wrangler/WranglerDevServer.ts"],"names":[],"mappings":"AAGA,OAAO,EAAS,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,EAAY,MAAM,EAAE,MAAM,yBAAyB,CAAA;;;;;;;;AAI3G;;GAEG;AACH,qBAAa,sBAAuB,SAAQ,2BAI1C;CAAG;AAEL;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;CAErB;AAED;;GAEG;AACH,MAAM,WAAW,0BAA0B;IACzC,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAC3B,GAAG,EAAE,MAAM,CAAA;IACX,sFAAsF;IACtF,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,qBAAqB;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,cAAc,CAAC,EAAE,QAAQ,CAAC,aAAa,CAAA;CACxC;;4BAYgB,0BAA0B;;;;;AAV3C;;;;;;;;GAQG;AACH,qBAAa,wBAAyB,SAAQ,6BAyF5C;CAAG"}
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import * as http from 'node:http';
|
|
2
|
-
import * as https from 'node:https';
|
|
3
1
|
import * as path from 'node:path';
|
|
4
2
|
import * as Toml from '@iarna/toml';
|
|
5
3
|
import { IS_CI } from '@livestore/utils';
|
|
@@ -78,78 +76,15 @@ export class WranglerDevServerService extends Effect.Service()('WranglerDevServe
|
|
|
78
76
|
* Verifies the server is actually accepting HTTP connections by making a test request
|
|
79
77
|
*/
|
|
80
78
|
const verifyHttpConnectivity = ({ url, showLogs, connectTimeout, }) => Effect.gen(function* () {
|
|
81
|
-
const
|
|
82
|
-
const shouldBypassProxy = isLoopbackHostname(parsedUrl.hostname);
|
|
79
|
+
const client = yield* HttpClient.HttpClient;
|
|
83
80
|
if (showLogs) {
|
|
84
|
-
|
|
85
|
-
yield* Effect.logDebug(`Verifying HTTP connectivity to ${url}${suffix}`);
|
|
81
|
+
yield* Effect.logDebug(`Verifying HTTP connectivity to ${url}`);
|
|
86
82
|
}
|
|
87
|
-
|
|
83
|
+
// Try to connect with retries using exponential backoff
|
|
84
|
+
yield* client.get(url).pipe(Effect.retryOrElse(Schedule.exponential('50 millis', 2).pipe(Schedule.jittered, Schedule.intersect(Schedule.elapsed.pipe(Schedule.whileOutput(Duration.lessThanOrEqualTo(connectTimeout)))), Schedule.compose(Schedule.count)), (error, attemptCount) => Effect.fail(new WranglerDevServerError({
|
|
88
85
|
cause: error,
|
|
89
86
|
message: `Failed to establish HTTP connection to Wrangler server at ${url} after ${attemptCount} attempts (timeout: ${Duration.toMillis(connectTimeout)}ms)`,
|
|
90
87
|
port: 0,
|
|
91
88
|
}))), Effect.tap(() => (showLogs ? Effect.logDebug(`HTTP connectivity verified for ${url}`) : Effect.void)), Effect.asVoid, Effect.withSpan('verifyHttpConnectivity'));
|
|
92
|
-
if (shouldBypassProxy) {
|
|
93
|
-
// When connecting to loopback, bypass HTTP(S)_PROXY entirely
|
|
94
|
-
yield* withRetries(loopbackConnectivityAttempt(parsedUrl, connectTimeout));
|
|
95
|
-
return;
|
|
96
|
-
}
|
|
97
|
-
const client = yield* HttpClient.HttpClient;
|
|
98
|
-
// Try to connect with retries using exponential backoff
|
|
99
|
-
yield* withRetries(client.get(url));
|
|
100
|
-
});
|
|
101
|
-
const loopbackConnectivityAttempt = (url, connectTimeout) => Effect.tryPromise({
|
|
102
|
-
try: () => {
|
|
103
|
-
const protocol = url.protocol;
|
|
104
|
-
const isHttps = protocol === 'https:';
|
|
105
|
-
const hostname = resolveLoopbackHostname(url.hostname);
|
|
106
|
-
const port = url.port === '' ? (isHttps ? 443 : 80) : Number(url.port);
|
|
107
|
-
const pathWithQuery = `${url.pathname}${url.search}` || '/';
|
|
108
|
-
const perAttemptTimeoutMillis = Math.min(Duration.toMillis(connectTimeout), 1_000);
|
|
109
|
-
return new Promise((resolve, reject) => {
|
|
110
|
-
const request = (isHttps ? https : http).request({
|
|
111
|
-
hostname,
|
|
112
|
-
port,
|
|
113
|
-
path: pathWithQuery,
|
|
114
|
-
method: 'GET',
|
|
115
|
-
timeout: perAttemptTimeoutMillis,
|
|
116
|
-
}, (response) => {
|
|
117
|
-
response.resume();
|
|
118
|
-
resolve();
|
|
119
|
-
});
|
|
120
|
-
request.on('error', reject);
|
|
121
|
-
request.on('timeout', () => {
|
|
122
|
-
request.destroy(new Error(`Request timed out after ${perAttemptTimeoutMillis}ms`));
|
|
123
|
-
});
|
|
124
|
-
request.end();
|
|
125
|
-
});
|
|
126
|
-
},
|
|
127
|
-
catch: (error) => error,
|
|
128
89
|
});
|
|
129
|
-
const isLoopbackHostname = (hostname) => {
|
|
130
|
-
const normalized = hostname.toLowerCase();
|
|
131
|
-
if (normalized === 'localhost') {
|
|
132
|
-
return true;
|
|
133
|
-
}
|
|
134
|
-
if (normalized === '0.0.0.0' || normalized === '::') {
|
|
135
|
-
return true;
|
|
136
|
-
}
|
|
137
|
-
if (normalized === '::1' || normalized === '0:0:0:0:0:0:0:1') {
|
|
138
|
-
return true;
|
|
139
|
-
}
|
|
140
|
-
if (normalized === '127.0.0.1' || normalized.startsWith('127.')) {
|
|
141
|
-
return true;
|
|
142
|
-
}
|
|
143
|
-
return false;
|
|
144
|
-
};
|
|
145
|
-
const resolveLoopbackHostname = (hostname) => {
|
|
146
|
-
const normalized = hostname.toLowerCase();
|
|
147
|
-
if (normalized === '0.0.0.0') {
|
|
148
|
-
return '127.0.0.1';
|
|
149
|
-
}
|
|
150
|
-
if (normalized === '::') {
|
|
151
|
-
return '::1';
|
|
152
|
-
}
|
|
153
|
-
return hostname;
|
|
154
|
-
};
|
|
155
90
|
//# sourceMappingURL=WranglerDevServer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WranglerDevServer.js","sourceRoot":"","sources":["../../src/wrangler/WranglerDevServer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,WAAW,CAAA;AACjC,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"WranglerDevServer.js","sourceRoot":"","sources":["../../src/wrangler/WranglerDevServer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,WAAW,CAAA;AACjC,OAAO,KAAK,IAAI,MAAM,aAAa,CAAA;AACnC,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAA;AACxC,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAA;AAC3G,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AACnD,OAAO,KAAK,QAAQ,MAAM,UAAU,CAAA;AAEpC;;GAEG;AACH,MAAM,OAAO,sBAAuB,SAAQ,MAAM,CAAC,WAAW,EAA0B,CAAC,wBAAwB,EAAE;IACjH,KAAK,EAAE,MAAM,CAAC,OAAO;IACrB,OAAO,EAAE,MAAM,CAAC,MAAM;IACtB,IAAI,EAAE,MAAM,CAAC,MAAM;CACpB,CAAC;CAAG;AAyBL;;;;;;;;GAQG;AACH,MAAM,OAAO,wBAAyB,SAAQ,MAAM,CAAC,OAAO,EAA4B,CAAC,0BAA0B,EAAE;IACnH,MAAM,EAAE,CAAC,IAAgC,EAAE,EAA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ev",
|
|
3
|
-
"version": "0.0.0-snapshot-
|
|
3
|
+
"version": "0.0.0-snapshot-9e97cae75eb5411b3aa53cfd87dcb082a536fc61",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": [
|
|
6
6
|
"./src/node-vitest/global.ts",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"./wrangler": "./dist/wrangler/mod.js"
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@effect/opentelemetry": "0.56.
|
|
15
|
+
"@effect/opentelemetry": "0.56.6",
|
|
16
16
|
"@effect/vitest": "0.25.1",
|
|
17
17
|
"@iarna/toml": "2.2.5",
|
|
18
18
|
"@opentelemetry/api": "1.9.0",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"@opentelemetry/sdk-trace-base": "2.0.1",
|
|
23
23
|
"@opentelemetry/sdk-trace-node": "2.0.1",
|
|
24
24
|
"wrangler": "4.32.0",
|
|
25
|
-
"@livestore/utils": "0.0.0-snapshot-
|
|
25
|
+
"@livestore/utils": "0.0.0-snapshot-9e97cae75eb5411b3aa53cfd87dcb082a536fc61"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {},
|
|
28
28
|
"files": [
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import * as http from 'node:http'
|
|
2
|
-
import * as https from 'node:https'
|
|
3
1
|
import * as path from 'node:path'
|
|
4
2
|
import * as Toml from '@iarna/toml'
|
|
5
3
|
import { IS_CI } from '@livestore/utils'
|
|
@@ -152,119 +150,31 @@ const verifyHttpConnectivity = ({
|
|
|
152
150
|
connectTimeout: Duration.DurationInput
|
|
153
151
|
}): Effect.Effect<void, WranglerDevServerError, HttpClient.HttpClient> =>
|
|
154
152
|
Effect.gen(function* () {
|
|
155
|
-
const
|
|
156
|
-
const shouldBypassProxy = isLoopbackHostname(parsedUrl.hostname)
|
|
153
|
+
const client = yield* HttpClient.HttpClient
|
|
157
154
|
|
|
158
155
|
if (showLogs) {
|
|
159
|
-
|
|
160
|
-
yield* Effect.logDebug(`Verifying HTTP connectivity to ${url}${suffix}`)
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
const withRetries = <A, R>(effect: Effect.Effect<A, unknown, R>) =>
|
|
164
|
-
effect.pipe(
|
|
165
|
-
Effect.retryOrElse(
|
|
166
|
-
Schedule.exponential('50 millis', 2).pipe(
|
|
167
|
-
Schedule.jittered,
|
|
168
|
-
Schedule.intersect(Schedule.elapsed.pipe(Schedule.whileOutput(Duration.lessThanOrEqualTo(connectTimeout)))),
|
|
169
|
-
Schedule.compose(Schedule.count),
|
|
170
|
-
),
|
|
171
|
-
(error, attemptCount) =>
|
|
172
|
-
Effect.fail(
|
|
173
|
-
new WranglerDevServerError({
|
|
174
|
-
cause: error,
|
|
175
|
-
message: `Failed to establish HTTP connection to Wrangler server at ${url} after ${attemptCount} attempts (timeout: ${Duration.toMillis(connectTimeout)}ms)`,
|
|
176
|
-
port: 0,
|
|
177
|
-
}),
|
|
178
|
-
),
|
|
179
|
-
),
|
|
180
|
-
Effect.tap(() => (showLogs ? Effect.logDebug(`HTTP connectivity verified for ${url}`) : Effect.void)),
|
|
181
|
-
Effect.asVoid,
|
|
182
|
-
Effect.withSpan('verifyHttpConnectivity'),
|
|
183
|
-
)
|
|
184
|
-
|
|
185
|
-
if (shouldBypassProxy) {
|
|
186
|
-
// When connecting to loopback, bypass HTTP(S)_PROXY entirely
|
|
187
|
-
yield* withRetries(loopbackConnectivityAttempt(parsedUrl, connectTimeout))
|
|
188
|
-
return
|
|
156
|
+
yield* Effect.logDebug(`Verifying HTTP connectivity to ${url}`)
|
|
189
157
|
}
|
|
190
158
|
|
|
191
|
-
const client = yield* HttpClient.HttpClient
|
|
192
|
-
|
|
193
159
|
// Try to connect with retries using exponential backoff
|
|
194
|
-
yield*
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
)
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
port,
|
|
215
|
-
path: pathWithQuery,
|
|
216
|
-
method: 'GET',
|
|
217
|
-
timeout: perAttemptTimeoutMillis,
|
|
218
|
-
},
|
|
219
|
-
(response) => {
|
|
220
|
-
response.resume()
|
|
221
|
-
resolve()
|
|
222
|
-
},
|
|
223
|
-
)
|
|
224
|
-
|
|
225
|
-
request.on('error', reject)
|
|
226
|
-
request.on('timeout', () => {
|
|
227
|
-
request.destroy(new Error(`Request timed out after ${perAttemptTimeoutMillis}ms`))
|
|
228
|
-
})
|
|
229
|
-
|
|
230
|
-
request.end()
|
|
231
|
-
})
|
|
232
|
-
},
|
|
233
|
-
catch: (error) => error as unknown,
|
|
160
|
+
yield* client.get(url).pipe(
|
|
161
|
+
Effect.retryOrElse(
|
|
162
|
+
Schedule.exponential('50 millis', 2).pipe(
|
|
163
|
+
Schedule.jittered,
|
|
164
|
+
Schedule.intersect(Schedule.elapsed.pipe(Schedule.whileOutput(Duration.lessThanOrEqualTo(connectTimeout)))),
|
|
165
|
+
Schedule.compose(Schedule.count),
|
|
166
|
+
),
|
|
167
|
+
(error, attemptCount) =>
|
|
168
|
+
Effect.fail(
|
|
169
|
+
new WranglerDevServerError({
|
|
170
|
+
cause: error,
|
|
171
|
+
message: `Failed to establish HTTP connection to Wrangler server at ${url} after ${attemptCount} attempts (timeout: ${Duration.toMillis(connectTimeout)}ms)`,
|
|
172
|
+
port: 0,
|
|
173
|
+
}),
|
|
174
|
+
),
|
|
175
|
+
),
|
|
176
|
+
Effect.tap(() => (showLogs ? Effect.logDebug(`HTTP connectivity verified for ${url}`) : Effect.void)),
|
|
177
|
+
Effect.asVoid,
|
|
178
|
+
Effect.withSpan('verifyHttpConnectivity'),
|
|
179
|
+
)
|
|
234
180
|
})
|
|
235
|
-
|
|
236
|
-
const isLoopbackHostname = (hostname: string): boolean => {
|
|
237
|
-
const normalized = hostname.toLowerCase()
|
|
238
|
-
|
|
239
|
-
if (normalized === 'localhost') {
|
|
240
|
-
return true
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
if (normalized === '0.0.0.0' || normalized === '::') {
|
|
244
|
-
return true
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
if (normalized === '::1' || normalized === '0:0:0:0:0:0:0:1') {
|
|
248
|
-
return true
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
if (normalized === '127.0.0.1' || normalized.startsWith('127.')) {
|
|
252
|
-
return true
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
return false
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
const resolveLoopbackHostname = (hostname: string): string => {
|
|
259
|
-
const normalized = hostname.toLowerCase()
|
|
260
|
-
|
|
261
|
-
if (normalized === '0.0.0.0') {
|
|
262
|
-
return '127.0.0.1'
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
if (normalized === '::') {
|
|
266
|
-
return '::1'
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
return hostname
|
|
270
|
-
}
|