onReq with finalhandler = Error
See original GitHub issueWhy this code is not working?
HttpProxy2.web(req, source.http.res, {
hostname: domainTarget.target.split("/")[0],
port: domainTarget.port,
onRes: function (req: Http2.Http2ServerRequest, res: Http2.Http2ServerResponse, proxyRes: Http.ServerResponse, callback: ()=>any) {
callback();
}
}, function (err: Error, req: Http.IncomingMessage | Http2.Http2ServerRequest, res: Http.ServerResponse | Http2.Http2ServerResponse){
if(err){
FinalHandler(req, res)(err);
}
});
Exception:
TypeError: Cannot read property 'Symbol(req)' of undefined
at onComplete (E:\***\***\node_modules\http2-proxy\index.js:165:18)
at Object.onRes (E:\***\***\lib\Worker.ts:332:29)
at ClientRequest.onProxyResponse (E:\***\***\node_modules\http2-proxy\index.js:269:24)
at ClientRequest.emit (events.js:182:13)
at HTTPParser.parserOnIncomingClient [as onIncoming] (_http_client.js:546:21)
at HTTPParser.parserOnHeadersComplete (_http_common.js:109:17)
at Socket.socketOnData (_http_client.js:432:20)
at Socket.emit (events.js:182:13)
at addChunk (_stream_readable.js:283:12)
at readableAddChunk (_stream_readable.js:264:11)
at Socket.Readable.push (_stream_readable.js:219:10)
at TCP.onread (net.js:639:20)
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
pillarjs/finalhandler: Node.js final http responder - GitHub
This function is to be invoked as fn(err) . If err is falsy, the handler will write out a 404 response to the...
Read more >node-http2-proxy - npm
No longer handles ends or destroys response on error. Use an appropriate error handler such as finalhandler .
Read more >How to fix finalhandler error when running npm install?
I'am trying to create a new Angular project from scratch running following command: ng new porjectName. but I get following error:
Read more >http2-proxy - UNPKG
35, console.error('proxy error', err). 36, finalhandler(req, res)(err). 37, }. 38, }. 39. 40, const defaultWSHandler = (err, req, socket, head) => {.
Read more >Http2-proxy - npm.io
Use a final and/or error handler since errored responses won't be cleaned up automatically. This makes it possible to perform retries. const finalhandler...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
That works, but I think its kind of confusing and ugly for my use case. I only want to set some Headers and with the old version 1.3.2 its easy to accomplish. A function to add Headers to the response would be nice.
By the way: The proxyRes from onRes is not a real Http.ServerResponse | Http2.Http2ServerResponse object … proxyRes.getHeaders() failed.
And thanks for your support and help
If you want to use it you have to handle the proxyRes => res logic, i.e.
You only need the callback if you want to finish before the usual life cycle of
proxyRes
andres
.