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

Fix bug of var m equals null(Hot fix for v1.7.2) #154

Closed
wants to merge 1 commit into from

Conversation

Projects
None yet
6 participants
@hori-ryota
Copy link

commented Jun 14, 2014

newrelic/lib/instrumentation/shared/connect-express.js:141
if (m.handle !== sentinel) {
^
TypeError: Cannot read property 'handle' of null

Fix bug of var m equals null
newrelic/lib/instrumentation/shared/connect-express.js:141
          if (m.handle !== sentinel) {
               ^
TypeError: Cannot read property 'handle' of null
@groundwater

This comment has been minimized.

Copy link
Contributor

commented Jun 14, 2014

That's no good 😦

I would like to add a test to guard against this fix from happening again. Can you describe your setup that caused the error?

@hori-ryota

This comment has been minimized.

Copy link
Author

commented Jun 15, 2014

express@4.0.0 or latest.

I start, and it occurs immediately.

Error message is here.

TypeError: Cannot read property 'handle' of null
    at cb_filter (/.../node_modules/newrelic/lib/instrumentation/shared/connect-express.js:135:16)
    at Array.filter (native)
    at Function.cls_wrapMiddlewareStack [as route] (/.../node_modules/newrelic/lib/instrumentation/shared/connect-express.js:128:31)
    at Function.proto.(anonymous function) [as get] (/.../node_modules/express/lib/router/index.js:446:22)
My dependency of package.json is here.

  "dependencies": {
    "async": "0.9.0",
    "basic-auth-connect": "1.0.0",
    "body-parser": "1.3.1",
    "compression": "1.0.7",
    "config": "0.4.36",
    "connect-flash": "0.1.1",
    "cookie-parser": "1.1.0",
    "debug": "1.0.2",
    "ejs": "1.0.0",
    "express": "4.4.3",
    "forever": "0.11.1",
    "lodash": "2.4.1",
    "memory-cache": "0.0.5",
    "mime": "1.2.11",
    "morgan": "1.1.1",
    "newrelic": "1.7.1",
    "passport": "0.2.0",
    "passport-facebook": "1.0.3",
    "passport-github": "0.1.5",
    "passport-google-oauth": "0.1.5",
    "passport-local": "1.0.0",
    "passport-twitter": "1.0.2",
    "proteus-cluster": "1.0.6",
    "proteus-logger": "1.2.3",
    "rethinkdb": "1.12.0-1",
    "rethinkdb-pool": "0.0.4",
    "validator": "3.16.0"
  }
@steverandy

This comment has been minimized.

Copy link

commented Jun 16, 2014

Got the same error. I noticed it's because I used express 4.0 router.

express = require "express"
router = express.Router()
router.get "/", (req, res) -> res.render "index"
module.exports = router
@groundwater

This comment has been minimized.

Copy link
Contributor

commented Jun 16, 2014

I tried reproducing this with the following snippet, using express@4.4.3

require('newrelic')

var http       = require('http')
var express    = require("express")
var bodyParser = require('body-parser')
var app        = express()

app.use(bodyParser.urlencoded())
app.use(bodyParser.json())
app.use(function(req,res,nxt){
  nxt()
})
app.use(function(err,req,res,nxt){
  nxt()
})
app.get("/", function (req, res) {
  res.send("index")
})

http.createServer(app).listen(8080)

I get no errors with newrelic@1.7.2. I am hesitant to include a fix without a repro case, or a test. We may be only patching a symptom versus fixing the root cause. We generally release every Thursday, so we still have some time to fix this before next release.

If you can help me refine the case and generate an error, that would be greatly appreciated.

@groundwater

This comment has been minimized.

Copy link
Contributor

commented Jun 17, 2014

Thanks to @marcbachmann for the (slightly modified) repro case below:

require('newrelic');
var express = require('express');
var router = express.Router();

router.get('/1', function(req, res, next) {
  next();
});

router.get('/2', function(req, res, next) {
  next();
});

This produces the following error:

/Users/jacob/Projects/NewRelic/BUGFIX/issue-155/node_modules/newrelic/lib/instrumentation/shared/connect-express.js:135
          if (m.handle !== sentinel) {
               ^
TypeError: Cannot read property 'handle' of null
    at cb_filter (/Users/jacob/Projects/NewRelic/BUGFIX/issue-155/node_modules/newrelic/lib/instrumentation/shared/connect-express.js:135:16)
    at Array.filter (native)
    at Function.cls_wrapMiddlewareStack [as route] (/Users/jacob/Projects/NewRelic/BUGFIX/issue-155/node_modules/newrelic/lib/instrumentation/shared/connect-express.js:128:31)
    at Function.proto.(anonymous function) [as get] (/Users/jacob/Projects/NewRelic/BUGFIX/issue-155/node_modules/express/lib/router/index.js:446:22)
    at Object.<anonymous> (/Users/jacob/Projects/NewRelic/BUGFIX/issue-155/index.js:9:8)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Function.Module.runMain (module.js:497:10)

I haven't resolved the underlying issue yet. Stay tuned.

@groundwater

This comment has been minimized.

Copy link
Contributor

commented Jun 19, 2014

Just an update.

This is an error in our instrumentation, and we're hoping to release a fix this week.

@groundwater

This comment has been minimized.

Copy link
Contributor

commented Jun 20, 2014

This should be fixed in 1.7.3.

Please let us know if this does, or does not resolve the issue.

Sorry about breaking things!

@oblador

This comment has been minimized.

Copy link

commented Jun 23, 2014

Still getting similar errors, but not on startup – only when requesting a page.

Using latest krakenjs which might complicate debugging, but doesn't seem to be involved judging by the stack trace.

TypeError: Cannot call method 'handle' of undefined
    at Function.app.handle (<project path>/node_modules/express/lib/application.js:124:16)
    at Layer.fn (<project path>/node_modules/express/lib/application.js:188:17)
    at Layer.eval [as handle] (eval at wrapHandle (<project path>/node_modules/newrelic/lib/instrumentation/express.js:246:41), <anonymous>:10:14)
    at trim_prefix (<project path>/node_modules/express/lib/router/index.js:252:17)
    at <project path>/node_modules/express/lib/router/index.js:216:9
    at Function.proto.process_params (<project path>/node_modules/express/lib/router/index.js:284:12)
    at Function.cls_wrapProcessParams [as process_params] (<project path>/node_modules/newrelic/lib/instrumentation/express.js:185:29)
    at next (<project path>/node_modules/express/lib/router/index.js:207:19)
    at next (<project path>/node_modules/express/lib/router/index.js:182:38)
    at <project path>/node_modules/newrelic/node_modules/continuation-local-storage/context.js:76:17
@groundwater

This comment has been minimized.

Copy link
Contributor

commented Jun 24, 2014

@oblador this looks like a different issue, so I've moved it to #160

@marcbachmann

This comment has been minimized.

Copy link

commented Jun 24, 2014

@groundwater Thanks, version 1.7.3 solved the problem with express.Router.

@txase

This comment has been minimized.

Copy link
Contributor

commented Jun 26, 2014

@marcbachmann Thanks for confirming! I'm going to close this issue now.

@txase txase closed this Jun 26, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.