Skip to content

Commit 55c97e8

Browse files
committed
Cleaner handler conditions
1 parent 842ad21 commit 55c97e8

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

lib/server-app.js

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -221,16 +221,15 @@ proto.middleware = function(name, paths, handler) {
221221
*/
222222
proto._findLayerByHandler = function(handler) {
223223
// Other handlers can be added to the stack, for example,
224-
// NewRelic adds sentinel handler. We need to search the stack
224+
// NewRelic adds sentinel handler, and AppDynamics adds
225+
// some additional proxy info. We need to search the stack
225226
for (var k = this._router.stack.length - 1; k >= 0; k--) {
226-
if (this._router.stack[k].handle === handler ||
227-
// NewRelic replaces the handle and keeps it as __NR_original
228-
this._router.stack[k].handle['__NR_original'] === handler ||
229-
// AppDynamics replaces the handle and keeps it as __appdynamicsProxyInfo__.orig
230-
(this._router.stack[k].handle['__appdynamicsProxyInfo__'] &&
231-
this._router.stack[k].handle['__appdynamicsProxyInfo__']['orig'] === handler
232-
)
233-
) {
227+
const isOriginal = this._router.stack[k].handle === handler;
228+
const isNewRelic = this._router.stack[k].handle['__NR_original'] === handler;
229+
const isAppDynamics = this._router.stack[k].handle['__appdynamicsProxyInfo__'] &&
230+
this._router.stack[k].handle['__appdynamicsProxyInfo__']['orig'] === handler;
231+
232+
if (isOriginal || isNewRelic || isAppDynamics) {
234233
return this._router.stack[k];
235234
} else {
236235
// Aggressively check if the original handler has been wrapped

0 commit comments

Comments
 (0)