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

Crash when express.Router() is used in different event loop #155

Closed
marcbachmann opened this issue Jun 16, 2014 · 2 comments
Closed

Crash when express.Router() is used in different event loop #155

marcbachmann opened this issue Jun 16, 2014 · 2 comments

Comments

@marcbachmann
Copy link

In my application I'm using the express.Router() class which got introduced in express v4.
I get an error when I try to initialize a route in a second event loop:

/app/node_modules/newrelic/lib/instrumentation/shared/connect-express.js:135
          if (m.handle !== sentinel) {
               ^
TypeError: Cannot read property 'handle' of null
  at cb_filter (/app/node_modules/newrelic/lib/instrumentation/shared/connect-express.js:135:16)
  at Array.filter (native)
  at Function.cls_wrapMiddlewareStack [as route] (/app/node_modules/newrelic/lib/instrumentation/shared/connect-express.js:128:31)
  at Function.proto.(anonymous function) [as get] (/app/node_modules/express/lib/router/index.js:446:22)
  at [object Object].<anonymous> (/app/index.coffee:10:10)
  at [object Object]._onTimeout (/app/node_modules/newrelic/node_modules/continuation-local-storage/node_modules/async-listener/glue.js:177:31)
  at Timer.listOnTimeout [as ontimeout] (timers.js:110:15)

How to reproduce it

In this example I force a new event loop using nextTick. But in reality I have some routes and some middlewares. That's why a few routes are initialized in a second event loop without calling nextTick.

  1. Create file: index.js
require('newrelic');
var express = require('express');
var router = express.Router();

router.get('/test', function(req, res, next) {
  console.log('test');
  next();
});

process.nextTick(function() {
  router.get('/test', function(req, res, next) {
    console.log('test');
    next();
  });
});
  1. Execute: node index.js

I'm using express v4.4.3, newrelic v1.7.2

@groundwater
Copy link
Contributor

Looks like this is the same as #154

I'm going to pull your repro case into there

@marcbachmann
Copy link
Author

Oh, I didn't notice that the problem always occurs with two route[verb] actions.
I thought there's only a problem when there are two event loops.
Thanks for pointing to the other issue and picking this up.

cmcadams-newrelic pushed a commit to cmcadams-newrelic/node-newrelic that referenced this issue Jan 29, 2024
feat: remove setLlmMetadata as the api has been removed. Update conversation_id to llm.conversation_id
jsumners-nr pushed a commit to jsumners-nr/node-newrelic that referenced this issue Apr 16, 2024
…/protobufjs-7.2.4

Bump protobufjs from 7.2.3 to 7.2.4
bizob2828 pushed a commit to bizob2828/node-newrelic that referenced this issue Apr 19, 2024
bizob2828 pushed a commit to bizob2828/node-newrelic that referenced this issue Apr 23, 2024
bizob2828 added a commit to bizob2828/node-newrelic that referenced this issue Jul 26, 2024
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

No branches or pull requests

2 participants