Fix Next.js runtime and deprecation warnings in the console
Problem
When running OpenMAIC locally, the console repeatedly reports Next.js runtime compatibility and deprecation warnings.
Although requests still complete successfully, these warnings create unnecessary noise, make real errors harder to identify, and may become build or runtime failures in future Next.js releases.
The following warnings have been identified:
instrumentation.tsusesprocess.once, which is unsupported in the Edge Runtime.- The project still uses the deprecated
middleware.tsfile convention instead ofproxy.ts. - Other repetitive console output may need review if it provides no diagnostic value.
Root Cause
Node.js APIs in instrumentation
Next.js compiles instrumentation.ts for both the Node.js and Edge runtimes. A runtime check using NEXT_RUNTIME does not prevent the Edge compiler from statically detecting process.once.
Node.js-specific startup and shutdown logic should be isolated in a separate module and dynamically imported only for the Node.js runtime.
Deprecated middleware convention
Next.js 16 has renamed the middleware.ts convention to proxy.ts. The exported middleware function should also be renamed to proxy.
Proposed Changes
- Move Node.js-specific startup, background-task, and signal-handling logic into a dedicated module.
- Dynamically import the Node.js instrumentation module only when
NEXT_RUNTIME === "nodejs". - Rename
middleware.tstoproxy.ts. - Rename the exported
middlewarefunction toproxy. - Preserve the existing access-code authentication, workbench feature gates, and route matcher behavior.
- Remove other redundant console output where appropriate without suppressing actionable errors.
Acceptance Criteria
- Local development no longer reports
process.once is not supported in the Edge Runtime. - Local development no longer reports
The "middleware" file convention is deprecated. - Access-code authentication behavior remains unchanged.
- Workbench feature-gating behavior remains correct.
- Unauthorized API requests still return
401. - Disabled workbench routes still return
404. - Relevant unit tests and lint checks pass.
- The production build completes without these warnings.
- Real errors are not hidden, swallowed, or downgraded merely to silence the console.
Source: THU-MAIC/OpenMAIC