rollbar / rollbar.js

Error tracking and logging from Javascript to Rollbar
https://docs.rollbar.com/docs/javascript
MIT License
571 stars 213 forks source link

autoInstrument is broken with got library #1103

Closed richardsimko closed 6 months ago

richardsimko commented 1 year ago

Repro repo: https://github.com/richardsimko/rollbar-got-issue

Using autoInstrument does not work at all with the very popular http request library got.

When running the referenced repo with ROLLBAR_ACCESS_TOKEN=<token> node test.js it produces the following error:

TypeError: callback.apply is not a function
    at ClientRequest.<anonymous> (/Users/richard/git/rollbar-got-issue/node_modules/rollbar/src/server/telemetry.js:119:23)
    at Object.onceWrapper (node:events:628:26)
    at ClientRequest.emit (node:events:525:35)
    at HTTPParser.parserOnIncomingClient [as onIncoming] (node:_http_client:693:27)
    at HTTPParser.parserOnHeadersComplete (node:_http_common:119:17)
    at TLSSocket.socketOnData (node:_http_client:535:22)
    at TLSSocket.emit (node:events:513:28)
    at addChunk (node:internal/streams/readable:324:12)
    at readableAddChunk (node:internal/streams/readable:297:9)
    at Readable.push (node:internal/streams/readable:234:10)

I believe the issue is in urlHelpers since it's assigning cb = options without checking that options actually is a function. Removing the assignment of cb = options does solve the issue, however I don't know what implications that might have for other things so I don't want to submit a PR with that as the solution.

https://github.com/rollbar/rollbar.js/blob/e964ecbdb16a4d2b8b5feaa8b70a2ec327648ed0/src/server/telemetry/urlHelpers.js#L20

waltjones commented 1 year ago

@richardsimko Thanks for the detailed report and test case. We'll take a look asap.

gerwinbrunner commented 1 year ago

we are running into the very same issue with got

metaskills commented 10 months ago

Same issue here.

neokoenig commented 9 months ago

Any update on this?

waltjones commented 6 months ago

Released in 2.26.4. https://github.com/rollbar/rollbar.js/releases/tag/v2.26.4. Thank you @jaridmargolin .