Function: runChain()
runChain(
handlers,req,res):Promise<void>
Defined in: service-core/src/http/MiddlewareChain.ts:20
Runs an ordered array of middleware handlers sequentially, Express-style.
Supports both 3-param (req, res, next) handlers and 4-param (err, req, res, next)
error handlers. On error, execution skips to the next error handler.
Each handler is awaited via a Promise that resolves when next() is called, not when the handler's return value resolves. This correctly handles: (1) sync handlers that call next() synchronously, (2) async handlers that return next() or await before calling it, and (3) sync handlers that schedule next() via callbacks such as setTimeout or socket.once. The chain terminates early when a handler ends the response without calling next().
Framework-agnostic — used by both the uWS-backed and Bun-backed routers.
Parameters
handlers
req
res
Returns
Promise<void>