From f135338d74bd473dafa463b954acd30bc94578e2 Mon Sep 17 00:00:00 2001 From: Richard R Date: Sun, 7 Jun 2026 06:09:14 -0600 Subject: [PATCH] chore(instrumentation): delegate node-specific setup to separate module Move Node.js-specific instrumentation logic to a dedicated file. Update registration to dynamically import the node module only when running in a Node.js environment. This separation clarifies environment-specific behavior and improves maintainability. --- src/instrumentation.node.ts | 5 +++++ src/instrumentation.ts | 8 +++----- 2 files changed, 8 insertions(+), 5 deletions(-) create mode 100644 src/instrumentation.node.ts diff --git a/src/instrumentation.node.ts b/src/instrumentation.node.ts new file mode 100644 index 0000000..b4b076c --- /dev/null +++ b/src/instrumentation.node.ts @@ -0,0 +1,5 @@ +import { startTaskScheduler } from '@/lib/server/tasks/scheduler'; + +if (!process.env.VERCEL) { + startTaskScheduler(); +} diff --git a/src/instrumentation.ts b/src/instrumentation.ts index 9095fae..43739b6 100644 --- a/src/instrumentation.ts +++ b/src/instrumentation.ts @@ -4,9 +4,7 @@ * nothing to keep a loop alive, so a cron route drives the ticks instead. */ export async function register(): Promise { - if (process.env.VERCEL) return; - if (process.env.NEXT_RUNTIME !== 'nodejs') return; - - const { startTaskScheduler } = await import('@/lib/server/tasks/scheduler'); - startTaskScheduler(); + if (process.env.NEXT_RUNTIME === 'nodejs') { + await import('./instrumentation.node'); + } }