Skip to content

onRequestError is not triggered for Route Handler when otel is enabled since Next.js 15.4.0 #82612

@yiminghe

Description

@yiminghe

Link to the code that reproduces this issue

https://github.com/yiminghe/on-request-error-bug

To Reproduce

  1. pnpm dev
  2. open http://localhost:3000/api
  3. check console

Current vs. Expected behavior

current (15.4.x, canary):
no error in console

expected(<15.4.0):
error in console

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 24.6.0: Mon Jul 14 11:30:40 PDT 2025; root:xnu-11417.140.69~1/RELEASE_ARM64_T8132
  Available memory (MB): 16384
  Available CPU cores: 10
Binaries:
  Node: 22.12.0
  npm: 11.4.2
  Yarn: 1.22.22
  pnpm: 10.12.3
Relevant Packages:
  next: 15.4.2-canary.44 // Latest available version is detected (15.4.2-canary.44).
  eslint-config-next: N/A
  react: 19.1.1
  react-dom: 19.1.1
  typescript: 5.9.2
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

Error Handling

Which stage(s) are affected? (Select all that apply)

Other (Deployed)

Additional context

if (!activeSpan && !(err instanceof NoFallbackError)) {

when otel is enabled, onRequestError is not called, not compatible with previous version.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Error HandlingRelated to handling errors (e.g., error.tsx, global-error.tsx).locked

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions