start phase 1

This commit is contained in:
Julius Marminge authored and Julius Marminge committed 2026-02-26 13:20:36 -08:00
1 parent 6954d1b91c
commit fefea0bdf6
16 files changed
+625 -4904

No files matched your search

+3 -2
View File
@@ -72,7 +72,7 @@ const isServerNotRunningError = (error: unknown): boolean => {
};
function rejectUpgrade(socket: Duplex, statusCode: number, message: string): void {
socket.write(
socket.end(
`HTTP/1.1 ${statusCode} ${statusCode === 401 ? "Unauthorized" : "Bad Request"}\r\n` +
"Connection: close\r\n" +
"Content-Type: text/plain\r\n" +
@@ -80,7 +80,6 @@ function rejectUpgrade(socket: Duplex, statusCode: number, message: string): voi
"\r\n" +
message,
);
socket.destroy();
}
function parseBooleanEnv(value: string | undefined): boolean | undefined {
@@ -506,6 +505,8 @@ export const createServer = Effect.fn(function* (options: ServerOptions = {}): E
});
httpServer.on("upgrade", (request, socket, head) => {
socket.on("error", () => {}); // Prevent unhandled `EPIPE`/`ECONNRESET` from crashing the process if the client disconnects mid-handshake
if (authToken) {
let providedToken: string | null = null;
try {