Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't add interceptor (error middleware) to Express Route's stack #207

Closed
wants to merge 1 commit into from

Conversation

itai-codefresh
Copy link

The current problem is that the error middleware that new relic adds to the main stack is also being added to every Router method's stack.
This means that the error middleware is actually being run twice, once from the Router method's stack and once from the general stack.
Besides this being wrong the other problem is that the cleanup function (line 398) that runs after the first error middleware finished removes the partialName thus causing the errors in new relic to appear without the specific url. it will only show '/' in the Errors view because of the cleanup.
The solution is to not add the error middleware for Router stacks. Add it only for the main stack.

The current problem is that the error middleware that new relic adds to the main stack is also being added to every Router method's stack.
This means that the error middleware is actually being run twice, once from the Router method's stack and once from the general stack.
Besides this being wrong the other problem is that the cleanup function (line 398) that runs after the first error middleware finished removes the partialName thus causing the errors in new relic to appear without the specific url. it will only show '/' in the Errors view because of the cleanup.
The solution is to not add the error middleware for Router stacks. Add it only for the main stack.
@itai-codefresh itai-codefresh changed the title Don't add interceptor (error middleware) to Routes stack Don't add interceptor (error middleware) to Express Routes stack Feb 21, 2016
@itai-codefresh itai-codefresh changed the title Don't add interceptor (error middleware) to Express Routes stack Don't add interceptor (error middleware) to Express Routes' stack Feb 21, 2016
@itai-codefresh itai-codefresh changed the title Don't add interceptor (error middleware) to Express Routes' stack Don't add interceptor (error middleware) to Express Route stack Feb 21, 2016
@itai-codefresh itai-codefresh changed the title Don't add interceptor (error middleware) to Express Route stack Don't add interceptor (error middleware) to Express Route's stack Feb 21, 2016
@itai-codefresh itai-codefresh deleted the patch-1 branch February 21, 2016 13:07
bizob2828 added a commit to bizob2828/node-newrelic that referenced this pull request Apr 19, 2024
chore: updated @newrelic/test-utilities to latest
bizob2828 added a commit to bizob2828/node-newrelic that referenced this pull request Apr 23, 2024
chore: updated @newrelic/test-utilities to latest
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant