-
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
lib: add --deprecate-soon and util.deprecateSoon() #9483
Conversation
This adds a non-intrusive mechanism for indicating that an API is expected to be deprecated "soon" where "soon" means at least the next semver-major Node.js release. The `DeprecateSoonWarning` is only emitted if the `--deprecate-soon` command line option is used which means the option will have zero impact for most situations. For those developers who wish to be proactively alerted to pending deprecations, use of the `--deprecate-soon` option can be used in testing/CI environments to determine which APIs may end up deprecated in the future. It should be noted that a "deprecate soon" warning is just a heads up, and that a decision can be made later NOT to deprecate the API if the change is deemed to be too intrusive.
Marking this in progress because I would like to get some discussion and input about whether this will be useful before landing. |
I don't think anyone outside of core will ever use such a flag, but maybe I'm wrong. I'd personally rather just use documentation deprecations to try to accomplish this. |
btw, sorry this wasn't clear, but the |
-1 "soon" is too vague and if the target use case is giving people a chance to change their code in advance, then the possibility of the deprecation being reverted means people could be worrying about nothing. Besides, I thought the whole idea behind the already-implemented warning system was to actively let people more know about changes coming "soon?" |
+1 for |
--deprecated-in-docs works also. On Saturday, November 5, 2016, Jeremiah Senkpiel notifications@github.com
|
I'm a bit confused about what it would mean to be deprecating a function "soon". If we have a warning discouraging the use of a function then it seems like the function is already deprecated, even if the warning is opt-in. If we're just holding off on emitting a warning by default until the next semver-major release, maybe we should call the flag |
Most of our other commandline arguments that don't take a parameter are of the form: It's a bit late to fix the existing inconsistency we have with |
+1 as a method of getting warnings on everything that is doc-deprecated (should be renamed to exclude -1 for introducing an additional deprecation step between the docs and runtime deprecation. |
Is the only difference between this and hard deprecation (aka runtime deprecation) that the former is disabled by default and the latter is enabled by default? |
Yes. |
Then it should be made clearer that it's basically the opposite of Maybe reuse the "hard/soft" terminology to distinguish "on-by-default" and "off-by-default" and reserve "runtime deprecation" for the actual warnings that depend on what the user has enabled? |
To clarify, this is the terminology I'm proposing: deprecation - deprecated API is marked with a scary-looking warning in the docs that tells the user to avoid it. Can be of two varieties: hard and soft. This also means that with cc @nodejs/collaborators I'd really like to know your opinion on this. |
@jasnell I'm very much in favour of this. It solves a real problem. Node.js wants to communicate to the user base that changes are coming, but the only way to do this at the moment dumps deprecation messages on the consoles of not just module authors (who can do something about it), but every single node user of grunt, strongloop's tools, ... basically, every CLI. Its way too loud a broadcast. Functional suggestions:
@seishun Its nice to have terminology, its confusing at the moment. I suggest renaming "runtime deprecated" to just "deprecated". Also, yours seems to lack a final deprecation, "actually gone"? I would suggest different names:
This seems like it implies like it would take 4 majors to get an API deprecated. |
Case in point:
If a deprecation is "proposed", then it's just that, a proposal. It doesn't make sense to add any warnings for something that may or may not happen. Going back to the
So introduce an extra deprecation stage before possible removal? I'm not sure if there is any point in that.
Not sure why this needs a name. It's basically "non-existent". |
@seishun Let me be clearer, given a set of words, "runtime, soft, hard", I suggest no one would be able to order them correctly, or guess their meaning. I had to read your proposal three times before I understood the difference between hard and runtime, so I appreciate the proposal to define terminology, but yours didn't work for me. You say:
But then you suggest the word "soft" for what @jasnell described as
James' description looks very much to me like what I would describe as "proposed deprecation". Also, I'd like to point out that soft and hard deprecation are words with already defined meanings. The new state is the one this PR proposes, its the one that should get a new name. If I understand your proposal, what used to be called "hard" is called "runtime", and what used to be called "soft" is now called "hard", and this new proposal of James' is called "soft". Did I misunderstand? Because changing the meaning of words to be their opposite isn't going to lead to clarity, but to more confusion. |
Aha, I see where the confusion is coming from. @jasnell originally proposed a So what used to be called "soft" remains "soft", but now with an option to enable runtime warnings for it. I've updated my terminology proposal to hopefully make things a bit clearer. |
IMO, |
@Trott if we add an option to warn on uses of all deprecated (whether or not there is a runtime warning by default) API, then we need to come up with terminology to distinguish API with "on-by-default" runtime warning (currently known as "hard deprecation" or "runtime deprecation") and API with "off-by-default" runtime warning (currently known as "soft deprecation" or "docs-only deprecation", but the latter would no longer be an adequate name after the option is added).
|
I agree with @Trott soft/hard is not intuitive. Something that tells me where it is in the process and the impact it will have on me would be much better. |
@jasnell could you please update the issue title and description to make it clear that it's for adding a runtime warning to API that's already deprecated, but currently docs-only? Clearly people are getting confused. (I'll delete this comment afterwards) |
Given the addition of the updated deprecation policy I'm going to hold off on this and close this PR. We can revisit this later if necessary |
Checklist
make -j8 test
(UNIX), orvcbuild test nosign
(Windows) passesAffected core subsystem(s)
lib, src
Description of change
This adds a non-intrusive mechanism for indicating that an API is expected to be deprecated "soon" where "soon" means at least the next semver-major Node.js release. The
DeprecateSoonWarning
is only emitted if the--deprecate-soon
command line option is used which means the option will have zero impact for most situations. For those developers who wish to be proactively alerted to pending deprecations, use of the--deprecate-soon
option can be used in testing/CI environments to determine which APIs may end up deprecated in the future.It should be noted that a "deprecate soon" warning is just a heads up, and that a decision can be made later NOT to deprecate the API if the change is deemed to be too intrusive.