env-runner 0.1.12 → 0.1.13
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.
|
@@ -30,7 +30,9 @@ var BaseEnvRunner = class {
|
|
|
30
30
|
}
|
|
31
31
|
async upgrade(context) {
|
|
32
32
|
if (!this.ready || !this._address) return;
|
|
33
|
-
|
|
33
|
+
try {
|
|
34
|
+
await proxyUpgrade(this._address, context.node.req, context.node.socket, context.node.head);
|
|
35
|
+
} catch {}
|
|
34
36
|
}
|
|
35
37
|
onMessage(listener) {
|
|
36
38
|
this._messageListeners.add(listener);
|
|
@@ -313,10 +313,12 @@ var MiniflareEnvRunner = class extends BaseEnvRunner {
|
|
|
313
313
|
}
|
|
314
314
|
const mfUrl = await this.#miniflare.unsafeGetDirectURL();
|
|
315
315
|
const address = new URL(mfUrl);
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
316
|
+
try {
|
|
317
|
+
await proxyUpgrade({
|
|
318
|
+
host: address.hostname,
|
|
319
|
+
port: Number(address.port)
|
|
320
|
+
}, context.node.req, context.node.socket, context.node.head);
|
|
321
|
+
} catch {}
|
|
320
322
|
}
|
|
321
323
|
async #prepareVirtualModules() {
|
|
322
324
|
const virtual = this._data?.virtual;
|
|
@@ -18,11 +18,15 @@ var SelfEnvRunner = class extends BaseEnvRunner {
|
|
|
18
18
|
}
|
|
19
19
|
async upgrade(context) {
|
|
20
20
|
if (!this.#entry || this.closed) return;
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
try {
|
|
22
|
+
if (this.#entry.websocket) {
|
|
23
|
+
await (await this.#resolveWSAdapter()).handleUpgrade(context.node.req, context.node.socket, context.node.head);
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
this.#entry.upgrade?.(context);
|
|
27
|
+
} catch {
|
|
28
|
+
if (!context.node.socket.destroyed) context.node.socket.destroy();
|
|
24
29
|
}
|
|
25
|
-
this.#entry.upgrade?.(context);
|
|
26
30
|
}
|
|
27
31
|
sendMessage(message) {
|
|
28
32
|
if (!this.#active) throw new Error("Self env runner should be initialized before sending messages.");
|