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

feat: support clearLockedPorts #70

Merged
merged 12 commits into from Mar 20, 2024

Conversation

nanianlisao
Copy link
Contributor

Previously, lockedPorts was not exported, which made it impossible to clear the cache.

By exporting lockedPorts, we can now manipulate it directly, allowing for cache clearing when necessary. This change will improve the flexibility of the library and allow users to better control the state of their applications.

Here is a brief overview of the changes:

  • Added an export for lockedPorts in the main library file.
  • Updated the documentation to reflect this new feature.

Please review these changes and let me know if you have any questions or concerns. Thank you for considering this contribution.

@sindresorhus
Copy link
Owner

I don't think this should be exported. If the need is to clear the cache, a clear cache function should be exported.

This contribution also feels ChatGPT generated. If it is, it should be made clear that it is.

@nanianlisao
Copy link
Contributor Author

@sindresorhus
Thank you for your feedback.
Indeed, I only need to clear the internal cache to ensure that each time getPort is called, the result is not interfered with.

I've changed it to export a function.

@nanianlisao nanianlisao changed the title chore: export lockedPorts feat: support clearLockedPorts Mar 12, 2024
index.d.ts Outdated Show resolved Hide resolved
test.js Outdated Show resolved Hide resolved
Copy link
Contributor Author

@nanianlisao nanianlisao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thx

index.d.ts Outdated Show resolved Hide resolved
index.d.ts Outdated Show resolved Hide resolved
index.d.ts Outdated Show resolved Hide resolved
readme.md Show resolved Hide resolved
@sindresorhus
Copy link
Owner

The docs should also note that clearing the cache could cause race conditions, since it makes this no longer true:

Race conditions in the same process are mitigated against by using a lightweight locking mechanism where a port will be held for a minimum of 15 seconds and a maximum of 30 seconds before being released again.

readme.md Outdated Show resolved Hide resolved
index.d.ts Outdated Show resolved Hide resolved
index.d.ts Outdated Show resolved Hide resolved
readme.md Outdated Show resolved Hide resolved
index.d.ts Outdated Show resolved Hide resolved
nanianlisao and others added 4 commits March 15, 2024 10:29
Co-authored-by: Sindre Sorhus <sindresorhus@gmail.com>
Co-authored-by: Sindre Sorhus <sindresorhus@gmail.com>
@sindresorhus sindresorhus merged commit d4fb7f8 into sindresorhus:main Mar 20, 2024
9 checks passed
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.

None yet

2 participants