Skip to content

util: replace process.noDeprecation with getOptionValue for deprecation handling #59063

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

bjohansebas
Copy link
Member

one less TODO

@nodejs-github-bot nodejs-github-bot added needs-ci PRs that need a full CI run. util Issues and PRs related to the built-in util module. labels Jul 14, 2025
@bjohansebas bjohansebas requested a review from joyeecheung July 14, 2025 01:52
Copy link

codecov bot commented Jul 14, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 90.06%. Comparing base (049664b) to head (70538e6).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #59063      +/-   ##
==========================================
- Coverage   90.06%   90.06%   -0.01%     
==========================================
  Files         645      645              
  Lines      189130   189129       -1     
  Branches    37094    37098       +4     
==========================================
- Hits       170339   170335       -4     
+ Misses      11511    11471      -40     
- Partials     7280     7323      +43     
Files with missing lines Coverage Δ
lib/internal/util.js 96.17% <100.00%> (-0.01%) ⬇️

... and 30 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@@ -182,8 +182,7 @@ function deprecate(fn, msg, code, useEmitSync, modifyPrototype = true) {
);

function deprecated(...args) {
// TODO(joyeecheung): use getOptionValue('--no-deprecation') instead.
if (!process.noDeprecation) {
if (!getOptionValue('--no-deprecation')) {
Copy link
Member

@jasnell jasnell Jul 14, 2025

Choose a reason for hiding this comment

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

Unfortunately I don't think we can change this in this way. The process.noDeprecate property can be set dynamically at runtime and there are applications out there that take advantage of it. This change would end up breaking those existing uses. The irony here would be that we'd likely need to deprecate the process.noDeprecation flag.

Copy link
Member Author

@bjohansebas bjohansebas Jul 14, 2025

Choose a reason for hiding this comment

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

That I didn't know, and honestly, I'm not sure if that support for doing it dynamically should be deprecated.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, in this case I think the TODO comment is just incorrect. As long as the option and the process.noDeprecation flag are compatible with each other and non-contradictory, then I would just remove the TODO comment and leave this as is.

Copy link
Member

@joyeecheung joyeecheung Jul 14, 2025

Choose a reason for hiding this comment

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

I think the TODO comment was left during refactoring when I was trying to figure out whether it's deprecatable at all - but at this point I am inclined to think that it is not as this shows up quite often in GitHub code search and also I am fairly certain there was one point I had to tell others to use it when there's no other alternative to avoid triggering excessive runtime warnings. It's probably better to document it instead of deprecating it at this point.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, the existing documentation (https://nodejs.org/docs/latest/api/process.html#processnodeprecation) leaves a lot to be desired.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-ci PRs that need a full CI run. util Issues and PRs related to the built-in util module.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants