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

[Feature] Make closeable #24

Closed
EthianWong opened this issue Oct 23, 2024 · 6 comments · Fixed by #25
Closed

[Feature] Make closeable #24

EthianWong opened this issue Oct 23, 2024 · 6 comments · Fixed by #25
Labels
enhancement New feature or request

Comments

@EthianWong
Copy link

Desc

In some cases, it may be necessary to dynamically enable and disable network debugging in a production environment, but there is currently no way to disable it. Will keeping it enabled continuously affect performance or memory consumption? Can a method to disable this feature be added?

To Resolve?

A reasonable cost for implementation makes adding a shutdown feature worthwhile in my opinion.

Resolutions(Optional)

...

@EthianWong EthianWong added the enhancement New feature or request label Oct 23, 2024
@GrinZero
Copy link
Owner

Hello 👋 May I ask what scenarios require dynamic activation and deactivation of network debugging in the production environment? I strongly do not recommend using node-network-devtools in production environments. Before issue #8 is resolved,node-network-devtools will store network debugging data based on memory, which can indeed affect performance or cause an increase in memory.

Meanwhile, if you expect dynamic activation, I would recommend using the following code to ensure that it only takes effect in the development environment.

import { register } from 'node-network-devtools'

process.env.NODE_ENV === 'development' && register()

@EthianWong
Copy link
Author

I agree with your point that node-network-devtools should not be used in a production environment.

However, emmm... sometimes reality doesn't match expectations. We are developing a Node.js client-side software (not server-side), and when troubleshooting issues on-site, we hope to observe network requests in a more intuitive way instead of through logs :)

I've made some simple modifications to the code, and it now achieves something similar to an 'unregister' function. From a broad perspective, this might not necessarily be a common requirement, but for a tool, if it can be opened, shouldn't it also be possible to close it?

Because turning it on will cause performance loss, it can be turned off when not needed (although I can also choose to restart our node program...)

Here are some code snippets.
image

If you think this idea is feasible, I can submit a merge request (MR).

@GrinZero
Copy link
Owner

I think this is great! Allow us to proactively eliminate side effects~

@EthianWong
Copy link
Author

I've committed the MR, and you can review it. Since I'm not very familiar with it, there might be some missed resource releases or rollbacks.

@GrinZero
Copy link
Owner

Right!

@GrinZero
Copy link
Owner

I will confirm and publish after I come back from exercise in the evening

@GrinZero GrinZero linked a pull request Oct 23, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants