express-http-proxy
express-http-proxy copied to clipboard
Converting circular structure to JSON because of debugger
The following line
JSON.stringify(processedReqOpts)
causes a TypeError: Converting circular structure to JSON
when defining a custom agent
. This is probably due to the internal implementation of require('http').Agent
.
You should rather use require('util').inspect
instead of JSON.stringify
Hi @matthieusieben, thanks for the report, happy to make this update. Can you give me a sample chunk with a custom agent that fails so I can pin this down with a test? Thanks.
const expressHttpProxy = require('express-http-proxy')
const { Agent: HttpAgent } = require('http')
const httpAgent = new HttpAgent({ keepAlive: true, keepAliveMsecs: 60e3 })
app.use(expressHttpProxy("http://localhost:3000", {
async proxyReqOptDecorator (proxyReqOpts, userReq) {
proxyReqOpts.agent = httpAgent
return proxyReqOpts
}
})
Thanks!
Huh. So I pushed the following (https://github.com/villadora/express-http-proxy/pull/393) which just has the tests, and I'm having trouble replicating the issue even without the fix applied.
I'm running the tests on CI right now to get information about if its environmentally related. Could you also provide detailed information about your environment? e.g., which version of node, express, debug do you have currently live, and what operating system.
If you don't mind looking at the test to see if you notice any conditions missing, I'd appreciate it. https://github.com/villadora/express-http-proxy/pull/393/files#diff-87ccb5f4d80dd2bb83e08f28ee236c31
- Does the proxyTarget "server" respect the keep-alive header and keeps the connection alive ?
- You may need to run two requests before it fails (so that the agent has one "alive" internal connection)
Any news on this? 1.5.0
is not usable with a custom agent
option.
The proper implementation is actually this one: #400