| ... | ... | @@ -87,6 +87,12 @@ import * as NetService from "@t3tools/shared/Net"; |
| 87 | 87 | import * as RelayClient from "@t3tools/shared/relayClient"; |
| 88 | 88 | import { disableTailscaleServe, ensureTailscaleServe } from "@t3tools/tailscale"; |
| 89 | 89 | |
| 90 | // Effect's default preemptive shutdown waits 20s before finalizing request scopes. |
| 91 | // T3's primary transport is long-lived WebSocket RPC, whose Effect scope finalizer |
| 92 | // already closes the websocket gracefully. Do not add an artificial drain before |
| 93 | // those finalizers get a chance to run. |
| 94 | const HTTP_PREEMPTIVE_SHUTDOWN_GRACE_MS = 0; |
| 95 | |
| 90 | 96 | const PtyAdapterLive = Layer.unwrap( |
| 91 | 97 | Effect.gen(function* () { |
| 92 | 98 | if (typeof Bun !== "undefined") { |
| ... | ... | @@ -116,6 +122,7 @@ const HttpServerLive = Layer.unwrap( |
| 116 | 122 | return BunHttpServer.layer({ |
| 117 | 123 | port: config.port, |
| 118 | 124 | ...(config.host ? { hostname: config.host } : {}), |
| 125 | gracefulShutdownTimeout: HTTP_PREEMPTIVE_SHUTDOWN_GRACE_MS, |
| 119 | 126 | }); |
| 120 | 127 | } else { |
| 121 | 128 | const [NodeHttpServer, NodeHttp] = yield* Effect.all([ |
| ... | ... | @@ -125,6 +132,7 @@ const HttpServerLive = Layer.unwrap( |
| 125 | 132 | return NodeHttpServer.layer(NodeHttp.createServer, { |
| 126 | 133 | host: config.host, |
| 127 | 134 | port: config.port, |
| 135 | gracefulShutdownTimeout: HTTP_PREEMPTIVE_SHUTDOWN_GRACE_MS, |
| 128 | 136 | }); |
| 129 | 137 | } |
| 130 | 138 | }), |