Glimpse / Home

Project Glimpse: Node Edition - Spend less time debugging and more time developing.
http://node.getglimpse.com
Other
252 stars 9 forks source link

Cannot read property 'hudScriptTemplate' of undefined error on 1st request #15

Closed focusaurus closed 8 years ago

focusaurus commented 8 years ago

node v6.5.0 on OSX

When I start my express app and load the first page I see this glimpse error:

Glimpse (101): Glimpse unexpected context value at location ExpressInspectorActionRouteView::onResponseRender().  Expecting context ID 72dd251077cf11e6a780919d90438b54.  Actual context ID is undefined
Glimpse (100): Glimpse was unable to retrieve the context associated with a request at location ExpressInspectorActionRouteView::onRenderComplete()
Glimpse (101): Glimpse unexpected context value at location ExpressInspectorActionRouteView::onResponseSend().  Expecting context ID 72dd251077cf11e6a780919d90438b54.  Actual context ID is undefined
Glimpse (100): Glimpse was unable to retrieve the context associated with a request at location ExpressInspectorActionRouteView::onRenderCompleteError()
{"time":"2016-09-11T03:25:55.419Z","hostname":"avi","pid":9878,"level":"error","name":"mjournal","message":"express error handler middleware","err":{"name":"TypeError","message":"Cannot read property 'hudScriptTemplate' of undefined","stack":"TypeError: Cannot read property 'hudScriptTemplate' of undefined\n    at ScriptManager.hudScript (/Users/plyons/projects/mjournal/node_modules/@glimpse/glimpse-node-agent/release/messaging/ScriptManager.js:28:42)\n    at ScriptManager.getScriptTagsForCurrentRequest (/Users/plyons/projects/mjournal/node_modules/@glimpse/glimpse-node-agent/release/messaging/ScriptManager.js:45:21)\n    at ExpressInspectorActionRouteView.onResponseSend (/Users/plyons/projects/mjournal/node_modules/@glimpse/glimpse-node-agent/release/inspectors/ExpressInspectorActionRouteView.js:204:50)\n    at Object.listener (/Users/plyons/projects/mjournal/node_modules/@glimpse/glimpse-node-agent/release/inspectors/ExpressInspectorActionRouteView.js:26:19)\n    at Tracing.publish (/Users/plyons/projects/mjournal/node_modules/@glimpse/glimpse-node-agent/release/tracing/Tracing.js:30:26)\n    at ServerResponse.sendResponse [as send] (/Users/plyons/projects/mjournal/node_modules/@glimpse/glimpse-node-agent/release/tracing/proxies/ExpressProxyActionRouteView.js:61:35)\n    at done (/Users/plyons/projects/mjournal/node_modules/@glimpse/glimpse-node-agent/release/tracing/proxies/ExpressProxyActionRouteView.js:104:22)\n    at onRenderComplete (/Users/plyons/projects/mjournal/node_modules/@glimpse/glimpse-node-agent/release/tracing/proxies/ExpressProxyActionRouteView.js:88:13)\n    at Object.exports.renderFile (/Users/plyons/projects/mjournal/node_modules/pug/lib/index.js:405:12)\n    at View.exports.__express [as engine] (/Users/plyons/projects/mjournal/node_modules/pug/lib/index.js:448:11)\n    at View.render [as originalRender] (/Users/plyons/projects/mjournal/node_modules/express/lib/view.js:126:8)\n    at View.viewRender [as render] (/Users/plyons/projects/mjournal/node_modules/@glimpse/glimpse-node-agent/release/tracing/proxies/ExpressProxyActionRouteView.js:28:31)\n    at tryRender (/Users/plyons/projects/mjournal/node_modules/express/lib/application.js:639:10)\n    at EventEmitter.render (/Users/plyons/projects/mjournal/node_modules/express/lib/application.js:591:3)\n    at ServerResponse.render (/Users/plyons/projects/mjournal/node_modules/express/lib/response.js:961:7)\n    at ServerResponse.renderResponse [as render] (/Users/plyons/projects/mjournal/node_modules/@glimpse/glimpse-node-agent/release/tracing/proxies/ExpressProxyActionRouteView.js:52:35)"}}
Glimpse (100): Glimpse was unable to retrieve the context associated with a request at location ExpressInspectorActionRouteView::onResponseEnd()
GET /glimpse/hud/main.js?hash={hash} 200 516.763 ms - 554299
Glimpse (100): Glimpse was unable to retrieve the context associated with a request at location ExpressInspectorActionRouteView::onResponseEnd()
GET /glimpse/agent/agent.js?hash={hash} 200 4.381 ms - 54744
Glimpse (100): Glimpse was unable to retrieve the context associated with a request at location ExpressInspectorActionRouteView::onResponseSend()
Glimpse (100): Glimpse was unable to retrieve the context associated with a request at location ExpressInspectorActionRouteView::onResponseEnd()
GET /glimpse/context/?contextId=72dd251077cf11e6a780919d90438b54&types=environment,user-identification,web-response,web-request,after-action-invoked,after-action-view-invoked,before-execute-command,after-execute-command,after-view-component 200 1.461 ms - 5418
Glimpse (100): Glimpse was unable to retrieve the context associated with a request at location ExpressInspectorActionRouteView::onResponseEnd()
GET /glimpse/hud/assets/glimpse-logo.png 200 0.961 ms - 810
Glimpse (100): Glimpse was unable to retrieve the context associated with a request at location ExpressInspectorActionRouteView::onResponseEnd()
GET /glimpse/hud/assets/selawk.woff2 200 0.839 ms - 14632
Glimpse (100): Glimpse was unable to retrieve the context associated with a request at location ExpressInspectorActionRouteView::onResponseSend()
Glimpse (100): Glimpse was unable to retrieve the context associated with a request at location ExpressInspectorActionRouteView::onResponseEnd()
POST /glimpse/message-ingress/ 202 16.843 ms - 8
Glimpse (100): Glimpse was unable to retrieve the context associated with a request at location ExpressInspectorActionRouteView::onResponseSend()
Glimpse (100): Glimpse was unable to retrieve the context associated with a request at location ExpressInspectorActionRouteView::onResponseEnd()
POST /glimpse/message-ingress/ 202 1.189 ms - 8

If I reload the page, the app starts working correctly. This only seems to happen on the first request after app startup. The glimpse HUD is visible on the page and otherwise seems to be working.

nikmd23 commented 8 years ago

Thanks for the report @focusaurus.

We've got this assigned to @avanderhoorn. He'll take a look and report when we can get a fix out.

mike-kaufman commented 8 years ago

We took a fix last week for some of the "unexpected context" errors, so hopefully a new build will clear those up.

RE the Cannot read property 'hudScriptTemplate' of undefined error, it looks like we have a race condition around when the resources get populated and when we try to access them via HUD. I've opened up a separate issue to track that here: Glimpse/Glimpse.Node.Prototype/issues/524.

philliphoff commented 8 years ago

This should be resolved (i.e. worked around, at least) with #528.

nikmd23 commented 8 years ago

528 is closed. Can we confirm if this is fixed?

philliphoff commented 8 years ago

The issue as reported is fixed, but there were 2 related issues that have fixes as well, but not all are yet released (as of 0.11.1). I'd wait to close this until verified with 0.11.2.

focusaurus commented 8 years ago

Issue is resolved for me with 0.11.1. Thanks!

nikmd23 commented 8 years ago

Thanks for the update @focusaurus!