Skip to content

Commit bd8d250

Browse files
committed
simpler check of nodejs runtime
1 parent f5bdb44 commit bd8d250

1 file changed

Lines changed: 2 additions & 25 deletions

File tree

packages/start/src/server/handler.ts

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -15,30 +15,6 @@ import { getExpectedRedirectStatus } from "./util.ts";
1515

1616
const SERVER_FN_BASE = "/_server";
1717

18-
try {
19-
const nodeHTTP = await import("http");
20-
const http2 = await import("http2");
21-
22-
function patchListen(proto: any) {
23-
if (!proto || proto.__patched) return;
24-
25-
const original = proto.listen;
26-
proto.listen = function (...args: any[]) {
27-
globalThis.CAN_SEND_FAST_NODE_STREAMS = true;
28-
return original.apply(this, args);
29-
};
30-
31-
proto.__patched = true;
32-
}
33-
34-
// http + https
35-
patchListen(nodeHTTP.Server.prototype);
36-
37-
// http2 (discover prototypes safely)
38-
patchListen(Object.getPrototypeOf(http2.createServer()));
39-
patchListen(Object.getPrototypeOf(http2.createSecureServer()));
40-
} catch {}
41-
4218
export function createBaseHandler(
4319
createPageEvent: (e: FetchEvent) => Promise<PageEvent>,
4420
fn: (context: PageEvent) => JSX.Element,
@@ -137,7 +113,8 @@ export function createBaseHandler(
137113

138114
// using TransformStream in dev can cause solid-start-dev-server to crash
139115
// when stream is cancelled
140-
if (globalThis.CAN_SEND_FAST_NODE_STREAMS) return stream;
116+
// send fast node streams (for now this is only available in nodejs)
117+
if (e.runtime?.name === "node") return stream;
141118

142119
// returning stream directly breaks cloudflare workers
143120
const { writable, readable } = new TransformStream();

0 commit comments

Comments
 (0)