Closed DrewML closed 1 month ago
@DrewML sorry for your troubles. Thanks for the repro, I'll triage and provide an update.
Thanks @bizob2828! Super appreciated.
@DrewML the Next.js instrumentation doesn't automatically handle errors. This example application demonstrates how to handle errors here. If you use this application you will see errors getting logged.
Moving this issue to node-newrelic
as the Next.js instrumentation has been merged into agent
I'm closing this based on my comment from 3 weeks ago. If this doesn't meet your needs, please reopen with more details
Description
I'm investigating an issue in my employer's app where we see an increase in 500 errors in New Relic, but these errors do not have any context or stack traces. Looking through our application logs, we see Next.js logging the actual error objects directly to
console.error
, but the NR agent doesn't seem to capture this info.As a test, we added some code locally to purposely throw, during a request to the
/
route, during the top-level execution of one of our modules. That code is:We then traced the execution path through Next.js code to determine where these errors were being passed to
console.error
, and determined the error is caught (and logged) inside ofrenderToResponseImpl
. The error is then passed to therenderErrorToResponse
method.My suspicion is that this package,
newrelic-node-nextjs
, is missing instrumentation of therenderErrorToResponse
method, which would unlock the ability to capture the Error object associated with the failed request and 500 error.Expected Behavior
If an exception is thrown as a side-effect of module initialization in the dependency graph for a Next.js app, that error is reported to New Relic.
Troubleshooting or NR Diag results
Steps to Reproduce
newrelic-node-nextjs
pages/index.tsx
, throw an error using the sample code provided in this ticket/
route in your browserYour Environment
next
version: 14.2.2@newrelic/next
version: 0.9.0node
version: 20.11.0Additional context