File tree Expand file tree Collapse file tree
packages/devframe/src/node Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -117,6 +117,16 @@ export interface StartHttpAndWsOptions {
117117 * own startup banner. Devframe does not print one itself.
118118 */
119119 onReady ?: ( info : { origin : string , port : number , app : H3 } ) => void | Promise < void >
120+ /**
121+ * Called for any error the HTTP server devframe owns emits after it starts
122+ * listening — e.g. a transient `EMFILE` while accepting a connection.
123+ * Without it such an error has no listener and crashes the process.
124+ *
125+ * Applies only to a server devframe created itself. When `server` is
126+ * supplied the caller owns that object and attaches to it directly, so
127+ * devframe leaves its error handling alone.
128+ */
129+ onServerError ?: ( error : Error ) => void
120130}
121131
122132export interface StartedServer {
@@ -287,6 +297,10 @@ export async function startHttpAndWs(options: StartHttpAndWsOptions): Promise<St
287297 cause : error ,
288298 } )
289299 }
300+ // Attached only now that the bind has already succeeded — this never
301+ // changes bind-time crash/hang semantics, only what happens afterward.
302+ if ( options . onServerError )
303+ httpServer . on ( 'error' , options . onServerError )
290304 }
291305
292306 const address = httpServer . address ( )
You can’t perform that action at this time.
0 commit comments