scoutapp / scout_apm_node

ScoutAPM Agent for NodeJS. Supports Express and other frameworks
https://scoutapm.com
Other
8 stars 9 forks source link

Incorrect check if agent is running on a TCP socket #260

Closed hellovietduc closed 3 years ago

hellovietduc commented 3 years ago

https://github.com/scoutapp/scout_apm_node/blob/748a1134119a0fef02b65c3d922e932dbb0f78dd/lib/scout/index.ts#L721-L734

I think the condition check for TCP socket type on line 728 is incorrect? It's comparing socketPath with AgentSocketType.TCP. Plus, line 729 doesn't get the correct raw port. socketPath comes with 2 colons if it's TCP (e.g. tcp://localhost:1234). It should be the one at index 2.

I can quickly submit a PR for this if it's confirmed a bug.

ghost commented 3 years ago

Hey @hellovietduc this actually does look like a bug -- that socketPath should defintely be socketType, and the socket path should be stripped of the prefix at that point (or taking the third item @ index 2). I'd appreciate a PR but I'm currently investigating an issue with NodeJS clustering which I can put this in with

hellovietduc commented 3 years ago

OK, I'll submit a PR to fix what's not working first