Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions instrumentation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ export async function register(): Promise<void> {
return shutdownPromise;
};

process.once('SIGTERM', () => void shutdown());
process.once('SIGINT', () => void shutdown());
// Imported dynamically so the Edge bundle never contains `process.once`.
const { registerShutdownSignals } = await import('@/lib/server/shutdown-signals');
registerShutdownSignals(shutdown);
}
11 changes: 11 additions & 0 deletions lib/server/shutdown-signals.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/**
* Node-only shutdown signal wiring.
*
* Kept out of `instrumentation.ts` so the Edge runtime bundle never contains
* `process.once`, which Next's Edge compiler rejects as a Node.js API. The
* parent module imports this dynamically and only on the Node.js runtime.
*/
export function registerShutdownSignals(shutdown: () => Promise<void>): void {
process.once('SIGTERM', () => void shutdown());
process.once('SIGINT', () => void shutdown());
}
Loading