From 3dcfc0cdd8f7c5df2bc92c68093743744166575a Mon Sep 17 00:00:00 2001 From: Aviv Keller Date: Mon, 23 Sep 2024 12:29:23 -0400 Subject: [PATCH] process: remove `process.assert` PR-URL: https://github.com/nodejs/node/pull/55035 Reviewed-By: Yagiz Nizipli Reviewed-By: Jake Yuesong Li Reviewed-By: Benjamin Gruenbaum Reviewed-By: James M Snell Reviewed-By: Rafael Gonzaga Reviewed-By: Chemi Atlow Reviewed-By: Marco Ippolito Reviewed-By: Matteo Collina --- doc/api/deprecations.md | 5 ++++- lib/internal/bootstrap/node.js | 11 +---------- lib/internal/process/per_thread.js | 5 ----- test/parallel/test-process-assert.js | 25 ------------------------- 4 files changed, 5 insertions(+), 41 deletions(-) delete mode 100644 test/parallel/test-process-assert.js diff --git a/doc/api/deprecations.md b/doc/api/deprecations.md index f10265b9ddd98a..6d3bcf75aa688b 100644 --- a/doc/api/deprecations.md +++ b/doc/api/deprecations.md @@ -2142,6 +2142,9 @@ parameter. -Type: Runtime +Type: End-of-Life `process.assert()` is deprecated. Please use the [`assert`][] module instead. diff --git a/lib/internal/bootstrap/node.js b/lib/internal/bootstrap/node.js index f7a62364b6107a..678e956dbd9e3c 100644 --- a/lib/internal/bootstrap/node.js +++ b/lib/internal/bootstrap/node.js @@ -67,10 +67,7 @@ const { } = primordials; const config = internalBinding('config'); const internalTimers = require('internal/timers'); -const { - defineOperation, - deprecate, -} = require('internal/util'); +const { defineOperation } = require('internal/util'); const { validateInteger, } = require('internal/validators'); @@ -265,12 +262,6 @@ ObjectDefineProperty(process, 'allowedNodeEnvironmentFlags', { configurable: true, }); -// process.assert -process.assert = deprecate( - perThreadSetup.assert, - 'process.assert() is deprecated. Please use the `assert` module instead.', - 'DEP0100'); - // TODO(joyeecheung): this property has not been well-maintained, should we // deprecate it in favor of a better API? const { isDebugBuild, hasOpenSSL, hasInspector } = config; diff --git a/lib/internal/process/per_thread.js b/lib/internal/process/per_thread.js index 70dcca3e8f0d96..506e7ee7ba2592 100644 --- a/lib/internal/process/per_thread.js +++ b/lib/internal/process/per_thread.js @@ -33,7 +33,6 @@ const { const { ErrnoException, codes: { - ERR_ASSERTION, ERR_INVALID_ARG_TYPE, ERR_INVALID_ARG_VALUE, ERR_OUT_OF_RANGE, @@ -53,9 +52,6 @@ let getValidatedPath; // We need to lazy load it because of the circular depende const kInternal = Symbol('internal properties'); -function assert(x, msg) { - if (!x) throw new ERR_ASSERTION(msg || 'assertion error'); -} const { exitCodes: { kNoFailure } } = internalBinding('errors'); const binding = internalBinding('process_methods'); @@ -428,7 +424,6 @@ const { arch, platform, version } = process; module.exports = { toggleTraceCategoryState, - assert, buildAllowedFlags, wrapProcessMethods, hrtime, diff --git a/test/parallel/test-process-assert.js b/test/parallel/test-process-assert.js deleted file mode 100644 index 2f0c3fc9430ce0..00000000000000 --- a/test/parallel/test-process-assert.js +++ /dev/null @@ -1,25 +0,0 @@ -'use strict'; -const common = require('../common'); -const assert = require('assert'); - -common.expectWarning( - 'DeprecationWarning', - 'process.assert() is deprecated. Please use the `assert` module instead.', - 'DEP0100' -); - -assert.strictEqual(process.assert(1, 'error'), undefined); -assert.throws(() => { - process.assert(undefined, 'errorMessage'); -}, { - code: 'ERR_ASSERTION', - name: 'Error', - message: 'errorMessage' -}); -assert.throws(() => { - process.assert(false); -}, { - code: 'ERR_ASSERTION', - name: 'Error', - message: 'assertion error' -});