question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ResponseInterceptor recipe types mismatch

See original GitHub issue

yarn why http-proxy-middleware OR npm ls http-proxy-middleware output (mask private folder names with *****)

comet@0.0.1 *****
├─┬ @types/http-proxy-middleware@1.0.0
│ └── http-proxy-middleware@2.0.0 deduped
└── http-proxy-middleware@2.0.0

Describe the bug (be clear and concise)

TL; DR; When using responseInterceptor on onProxyRes, types doesn’t match.

In detail…

I wanted to handle response. So I used a function on [onProxyRes] (https://github.com/chimurai/http-proxy-middleware/issues/97#issuecomment-268180448).

but I didn’t get the response as I wanted… (Response was broken and I think it’s related to decompressing… it’s not the issue I wanna report anyways)

So, instead of using this

proxyRes.on('data', ....) 

I used responseInterceptor with your recipe

I’m using Typescript also, and unfortunately, responseInterceptor’s return value doesn’t comply to onProxyRes.

Step-by-step reproduction instructions

I attached my code here.

https://gist.github.com/hotsummmer/387aba337e4a62ee0182a4587995f3db

Expected behavior (be clear and concise)

responseInterceptor expects arguments as below

(buffer: Buffer, proxyRes: http.IncomingMessage, req: http.IncomingMessage, res: http.ServerResponse)

but if I want to use it directly onProxyReq, types doesn’t match.

Because onProxyRes expects this type.

onProxyRes: (
        proxyRes: IncomingMessage,
        req: Request,
        res: Response,
    ): void 

It works if I use any as expected type… or convert types before passing it to responseInterceptor. But wanted to ask you first about this issue

What http-proxy-middleware configuration are you using?

Line 16~33.

https://gist.github.com/hotsummmer/387aba337e4a62ee0182a4587995f3db

What OS/version and node/version are you seeing the problem?

MacOS 11.4, Node 12.18.3

Additional context (optional)

I appreciate your work and wonderful recipes! Happy to use it and contribute 😃 thanks ❤️

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
hotsummmercommented, Jul 2, 2021

Just published v2.0.1.

onProxyRes is now typed as:

onProxyRes: (
  proxyRes: http.IncomingMessage,
  req: http.IncomingMessage,
  res: http.ServerResponse
): void 

Hopefully it won’t give conflicts anymore.

Let me know if the issue persists.

Wow. Thanks for taking care of it right away 👍 I will check on it!

1reaction
chimuraicommented, Jul 1, 2021

Just published v2.0.1.

onProxyRes is now typed as:

onProxyRes: (
  proxyRes: http.IncomingMessage,
  req: http.IncomingMessage,
  res: http.ServerResponse
): void 

Hopefully it won’t give conflicts anymore.

Let me know if the issue persists.

Read more comments on GitHub >

github_iconTop Results From Across the Web

http-proxy-middleware - Bountysource
ResponseInterceptor recipe types mismatch $ 0. Created 1 year ago in chimurai/http-proxy-middleware with 6 comments. yarn why http-proxy- ...
Read more >
Issues · chimurai/http-proxy-middleware · GitHub
ResponseInterceptor recipe types mismatch bug. #632 opened on Jun 30, 2021 by hotsummmer. 2 tasks done. 7. ERR_HTTP_HEADERS_SENT from onProxyReq with keep- ...
Read more >
Type mismatch error in making HTTP request - Stack Overflow
You have two conflicting versions on bytestring package. Try ghc-pkg list bytestring . I'd suggest you to cabalize your code and use cabal...
Read more >
How to Forward One Https Request to Two Servers Using Nodejs ...
ResponseInterceptor recipe types mismatch 0.Created 11 months ago in chimurai/httpproxymiddleware with 6 comments.yarn why httpproxy.
Read more >
Incident Response Report False-Positive - Hybrid Analysis
... see * {@link providers#provider-recipe Provider Recipe}. ... automatically add an "unknown" option, which it then removes when the mismatch is resolved.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found