-
Notifications
You must be signed in to change notification settings - Fork 30.1k
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
Clarify behavior of require('http') and require('node:http') with existing require.cache entries #52992
Closed
Closed
Clarify behavior of require('http') and require('node:http') with existing require.cache entries #52992
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would be more direct, at the risk of being vague: mutation of the module cache is a thing in CJS, but that shouldn't matter for most users – and for those for which it does matter, it seems fair to assume they won't need the extra details.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As a newcomer to this, I find the wording "assuming no mutation of the module cache" somewhat confusing.
My goal is to clearly understand the specification, and this phrase doesn't help clarify the situation for me.
I believe my initial wording is preferable because it explicitly states the technical condition under which the behavior differs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How is it confusing, and how can we clear up that confusion?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I find the wording "assuming no mutation of the module cache" somewhat confusing because it implies that mutations exist, which begs the question: "under what circumstances?" My wording describes the specification as it is. As for how to move forward, feel free to decide how to write this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that's fine, the rest of the documentation should contain the answer to that question. Maybe it's clearer if we say
require.cache
instead of "the module cache"If you look at the section just above this one, it already deals with how caching works in CJS
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO it should be past tense, 'assuming
require.cache
has not been modified'There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI, I initially raised this question in the IRC, and the reply I got indicated that there is an impression that core modules are not served from the cache at all, which suggests that this is not so clear. Just my 2c.