You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
middleware: init/dispose lifecycle hooks for connection pools #683
The file-convention middleware (src/middleware.ts exporting defineMiddleware) has no init/dispose hooks. A database pool used by the middleware can only be opened at module scope (or lazily in a memoised getter), and there is no documented way to release it on function shutdown. In the invoicing example this forced a lazy, reset-on-rejection getter pattern that every app will have to reinvent.
Proposal
Optional lifecycle hooks on the middleware definition, e.g. defineMiddleware({ setup(ctx) {…}, dispose() {…}, handle(req, ctx) {…} }), with dispose wired to the runtime shutdown path for each target.
Activity