Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create proxy instance for each request #65

Merged
merged 8 commits into from
Mar 12, 2022
Merged

Create proxy instance for each request #65

merged 8 commits into from
Mar 12, 2022

Conversation

johannbrynjar
Copy link
Contributor

@johannbrynjar johannbrynjar commented Mar 12, 2022

Global proxy instance make memory leak. So I would like to create proxy for each request.

Every request init proxy so each request add new events:

onProxyInit(proxy);

Also here for each request the code add new event listener:

.once("error", reject)

I think this issue #25 is related to this pull request.

stegano and others added 7 commits March 3, 2022 16:57
build(deps-dev): bump next from 11.1.3 to 12.1.0
According to [the doc](https://www.npmjs.com/package/http-proxy#listening-for-proxy-events) the `proxyReq` event gets
```http.ClientRequest proxyReq, http.IncomingMessage req, http.ServerResponse res, Object options)```

I just fixed the name of the first parameter
Updated README for the proxyReq signature
docs: add dariosky as a contributor for doc
@stegano
Copy link
Owner

stegano commented Mar 12, 2022

Hi @johannbrynjar

Thanks for your PR

I understood the memory leak you are talking about.
(An event handler is bound for each request, but the binding is maintained if no event (resolve or error) occurs)

However, even after this PR is merged, each instance bound to the event is still in memory, so memory leak is likely.

Let's find another way to solve this memory leak problem.
Please let me know if I'm wrong.

@stegano
Copy link
Owner

stegano commented Mar 12, 2022

@all-contributors please add @johannbrynjar for bug

@allcontributors
Copy link
Contributor

@stegano

I've put up a pull request to add @johannbrynjar! 🎉

@stegano
Copy link
Owner

stegano commented Mar 12, 2022

@johannbrynjar
I just released v1.2.3 version that fixed the memory leak problem.
I wouldn't have found this problem without you.
Thank you. 😀

@stegano
Copy link
Owner

stegano commented Mar 12, 2022

Hi @johannbrynjar

Thanks for your PR

I understand the memory leak you are talking about. (An event handler is bound for each request, but the binding is maintained if no event (resolve or error) occurs)

However, even after this PR is merged, each instance bound to the event is still in memory, so memory leak is likely.

Let's find another way to solve this memory leak problem. Please let me know if I'm wrong.

There was a mistake. Your PR seems fine. Even if the event is bound to the instance, it will be removed from memory by GC when the scope is closed.

@stegano stegano merged commit c5bcd1c into stegano:master Mar 12, 2022
@stegano
Copy link
Owner

stegano commented Mar 12, 2022

@all-contributors please add @johannbrynjar for code

@allcontributors
Copy link
Contributor

@stegano

I've put up a pull request to add @johannbrynjar! 🎉

@johannbrynjar johannbrynjar deleted the FixMemoryLeak branch March 12, 2022 18:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants