TooTallNate / proxy-agents

Node.js HTTP Proxy Agents Monorepo
https://proxy-agents.n8.io
919 stars 239 forks source link

Don't depend on stack trace format #158

Closed rightaway closed 1 year ago

rightaway commented 1 year ago

This depends on default stack trace output

https://github.com/TooTallNate/node-agent-base/blob/0288bc26f856dd0473a2923241dfbf1ab67b99b0/src/index.ts#L18

With Error.prepareStackTrace https://v8.dev/docs/stack-trace-api#customizing-stack-traces there's no guarantee about its format or that it is even a string. Official v8 docs say that "User stack trace formatters are free to format the stack trace however they want and even return non-string values"

https://github.com/TooTallNate/node-agent-base/issues/63

TooTallNate commented 1 year ago

I'm curious, can you share an example where this becomes problematic? I agree it's not a great hack, but it seems like the most reliable way to determine when the agent should be in http vs. https mode. In the past, this module monkey patched https.request, which was less ideal IMO.

rightaway commented 1 year ago

It's for using the stack trace to get metadata that can be used in development tools. Could it default to whichever agent type is more common http or https, and a config setting can be passed to change it if necessary?

TooTallNate commented 1 year ago

I'd be down to accept a PR adding a config option to make an agent instance be explicitly "locked" for use with either http or https.