From 82751d20a69783da1af118e0b2ee0a1a0b2848de Mon Sep 17 00:00:00 2001 From: Peter Svetlichny Date: Fri, 23 Mar 2018 14:17:31 -0700 Subject: [PATCH 1/3] fix(hapi): return string pre handlers --- lib/instrumentation/hapi.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/instrumentation/hapi.js b/lib/instrumentation/hapi.js index e03e9567a0..9856ecc63a 100644 --- a/lib/instrumentation/hapi.js +++ b/lib/instrumentation/hapi.js @@ -146,6 +146,10 @@ function wrapPreHandlers(shim, container, path) { return _wrapPreHandler(handler) }) } + // The 'pre' option also allows strings pointing to methods registered via + // server.method() (ie: 'methodName(args)'). For the most part, these should + // be simple utility functions, but may be something we want to wrap in the future. + return container function _wrapPreHandler(handler) { return shim.recordMiddleware( From b4fc0414468464ead399c2863fda165cfdd3492e Mon Sep 17 00:00:00 2001 From: Peter Svetlichny Date: Fri, 23 Mar 2018 14:17:44 -0700 Subject: [PATCH 2/3] test(hapi): test string pre handler --- test/versioned/hapi/hapi-pre-17/router-v16.tap.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/test/versioned/hapi/hapi-pre-17/router-v16.tap.js b/test/versioned/hapi/hapi-pre-17/router-v16.tap.js index 9633e36c96..3b731ee378 100644 --- a/test/versioned/hapi/hapi-pre-17/router-v16.tap.js +++ b/test/versioned/hapi/hapi-pre-17/router-v16.tap.js @@ -90,6 +90,11 @@ tap.test('Hapi router introspection', function(t) { t.test('using `pre` config option', function(t) { agent.on('transactionFinished', utils.verifier(t)) + server.method('test', function(arg, next) { + t.ok(agent.getTransaction(), 'transaction available in server method') + next() + }) + var route = { method: 'GET', path: '/test/{id}', @@ -99,6 +104,9 @@ tap.test('Hapi router introspection', function(t) { t.ok(agent.getTransaction(), 'transaction available in plain `pre` function') reply() }, + { + method: 'test' + }, [ { method: function nested(req, reply) { From 7837b6e54b275ee2e5cae743ee6240bf43e33476 Mon Sep 17 00:00:00 2001 From: Peter Svetlichny Date: Fri, 23 Mar 2018 14:36:48 -0700 Subject: [PATCH 3/3] test(restify): pin test version to <7 --- test/versioned/restify/package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/versioned/restify/package.json b/test/versioned/restify/package.json index 8683df4771..0ed8d8acb0 100644 --- a/test/versioned/restify/package.json +++ b/test/versioned/restify/package.json @@ -25,7 +25,7 @@ "node": "^0.10" }, "dependencies": { - "restify": ">=5.0.0 <6.3.4 || >6.3.4", + "restify": ">=5.0.0 <6.3.4 || >6.3.4 <7", "express": "4.16" }, "files": [ @@ -41,7 +41,7 @@ "node": ">=0.11.0" }, "dependencies": { - "restify": ">=5.0.0", + "restify": ">=5.0.0 <7", "express": "4.16" }, "files": [