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

Instrumenting route-start and route-done in DTrace cause restify to crash #1648

Closed
Smithx10 opened this issue Apr 23, 2018 · 2 comments
Closed

Comments

@Smithx10
Copy link

Starting in restify version 7 dtrace will crash restify if you instrument route-start or route-done.

start application:

bruce.smith@Bruces-MacBook-Pro /g/f/r/f/src ❯❯❯ node api.js                                                                                                            ⏎ master ◼
{"name":"fibo-api","hostname":"Bruces-MacBook-Pro.local","pid":58139,"app_type":"fibo-restify","level":30,"msg":"ready on http://[::]:8080","time":"2018-04-23T15:21:52.441Z","v":0}

instrument the probe:

    bruce.smith@Bruces-MacBook-Pro /g/f/rest-fibo ❯❯❯ sudo dtrace -n 'restify58139:::route-start'                                                                            master ◼
dtrace: system integrity protection is on, some features will not be available

dtrace: description 'restify58139:::route-start' matched 1 probe

hit the api:

curl localhost:8080/api/fibo/4

node throws:

/git/for-virtu/rest-fibo/fibo/src/node_modules/restify/lib/router.js:346
            req.route.name,
                      ^

TypeError: Cannot read property 'name' of undefined
    at DTraceProbe.fire (/git/for-virtu/rest-fibo/fibo/src/node_modules/restify/lib/router.js:346:23)
    at Router._dtraceStart (/git/for-virtu/rest-fibo/fibo/src/node_modules/restify/lib/router.js:343:41)
    at Router.lookup (/git/for-virtu/rest-fibo/fibo/src/node_modules/restify/lib/router.js:78:10)
    at Server._runRoute (/git/for-virtu/rest-fibo/fibo/src/node_modules/restify/lib/server.js:906:36)
    at Server._afterPre (/git/for-virtu/rest-fibo/fibo/src/node_modules/restify/lib/server.js:888:10)
    at Immediate.preChainDone [as _onImmediate] (/git/for-virtu/rest-fibo/fibo/src/node_modules/restify/lib/server.js:856:14)
    at runCallback (timers.js:764:11)
    at tryOnImmediate (timers.js:734:5)
    at processImmediate (timers.js:716:5)
    at process.topLevelDomainCallback (domain.js:101:23)
@DonutEspresso
Copy link
Member

@hekike it looks like dtraceStart expects req.route, but we haven't looked up the route yet when it gets fired. I think in the router migration there are probably a few of the dtrace hooks that haven't been migrated ?

@hekike
Copy link
Member

hekike commented May 14, 2018

It was also fired at the wrong place, here is a fix: #1659

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

3 participants