From 0f7ea98e4be412483b7efdd419ee8bb380d3dd16 Mon Sep 17 00:00:00 2001 From: Miguel Marcondes Date: Sat, 10 May 2025 15:05:46 -0300 Subject: [PATCH 1/3] doc: deprecate utilisNativeError in favor of ErrorisError --- doc/api/deprecations.md | 16 ++++++++++++++++ doc/api/util.md | 4 ++++ 2 files changed, 20 insertions(+) diff --git a/doc/api/deprecations.md b/doc/api/deprecations.md index 88f051904f8b7c..1719488d737654 100644 --- a/doc/api/deprecations.md +++ b/doc/api/deprecations.md @@ -3918,6 +3918,20 @@ Type: Runtime The `node:_tls_common` and `node:_tls_wrap` modules are deprecated as they should be considered an internal nodejs implementation rather than a public facing API, use `node:tls` instead. +### DEP0193: `util.types.isNativeError()` + + + +Type: Documentation-only + +The [`util.types.isNativeError`][] API is deprecated. Please use [`Error.isError`][] instead. + [DEP0142]: #dep0142-repl_builtinlibs [NIST SP 800-38D]: https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38d.pdf [RFC 6066]: https://tools.ietf.org/html/rfc6066#section-3 @@ -3935,6 +3949,7 @@ an internal nodejs implementation rather than a public facing API, use `node:tls [`Buffer.isBuffer()`]: buffer.md#static-method-bufferisbufferobj [`Cipheriv`]: crypto.md#class-cipheriv [`Decipheriv`]: crypto.md#class-decipheriv +[`Error.isError`]: https://github.com/tc39/proposal-is-error [`REPLServer.clearBufferedCommand()`]: repl.md#replserverclearbufferedcommand [`ReadStream.open()`]: fs.md#class-fsreadstream [`Server.getConnections()`]: net.md#servergetconnectionscallback @@ -4046,6 +4061,7 @@ an internal nodejs implementation rather than a public facing API, use `node:tls [`util.isArray()`]: util.md#utilisarrayobject [`util.promisify`]: util.md#utilpromisifyoriginal [`util.toUSVString()`]: util.md#utiltousvstringstring +[`util.types.isNativeError`]: util.md#utiltypesisnativeerrorvalue [`util.types`]: util.md#utiltypes [`util`]: util.md [`worker.exitedAfterDisconnect`]: cluster.md#workerexitedafterdisconnect diff --git a/doc/api/util.md b/doc/api/util.md index 413b05cb5d9694..3e22d45be273f7 100644 --- a/doc/api/util.md +++ b/doc/api/util.md @@ -3319,8 +3319,11 @@ util.types.isModuleNamespaceObject(ns); // Returns true +> Stability: 0 - Deprecated: Use [`Error.isError`][] instead. + * `value` {any} * Returns: {boolean} @@ -3707,6 +3710,7 @@ util.isArray({}); [`'warning'`]: process.md#event-warning [`Array.isArray()`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/isArray [`ArrayBuffer.isView()`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/isView +[`Error.isError`]: https://github.com/tc39/proposal-is-error [`JSON.stringify()`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify [`MIMEparams`]: #class-utilmimeparams [`Object.assign()`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign From b026b3cb261a98a72c7ba41eb49337b5948a8020 Mon Sep 17 00:00:00 2001 From: Miguel Marcondes Date: Mon, 12 May 2025 07:48:16 -0300 Subject: [PATCH 2/3] doc: update links for ErrorisError to point to MDN --- doc/api/deprecations.md | 2 +- doc/api/util.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/api/deprecations.md b/doc/api/deprecations.md index 1719488d737654..62a3795407d8c9 100644 --- a/doc/api/deprecations.md +++ b/doc/api/deprecations.md @@ -3949,7 +3949,7 @@ The [`util.types.isNativeError`][] API is deprecated. Please use [`Error.isError [`Buffer.isBuffer()`]: buffer.md#static-method-bufferisbufferobj [`Cipheriv`]: crypto.md#class-cipheriv [`Decipheriv`]: crypto.md#class-decipheriv -[`Error.isError`]: https://github.com/tc39/proposal-is-error +[`Error.isError`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/isError [`REPLServer.clearBufferedCommand()`]: repl.md#replserverclearbufferedcommand [`ReadStream.open()`]: fs.md#class-fsreadstream [`Server.getConnections()`]: net.md#servergetconnectionscallback diff --git a/doc/api/util.md b/doc/api/util.md index 3e22d45be273f7..d75f4491f99557 100644 --- a/doc/api/util.md +++ b/doc/api/util.md @@ -3710,7 +3710,7 @@ util.isArray({}); [`'warning'`]: process.md#event-warning [`Array.isArray()`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/isArray [`ArrayBuffer.isView()`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/isView -[`Error.isError`]: https://github.com/tc39/proposal-is-error +[`Error.isError`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/isError [`JSON.stringify()`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify [`MIMEparams`]: #class-utilmimeparams [`Object.assign()`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign From 0eac59208bd6287f71af34818a53d91164bcca76 Mon Sep 17 00:00:00 2001 From: Miguel Marcondes Date: Fri, 16 May 2025 18:04:09 -0300 Subject: [PATCH 3/3] doc: add performance note for ErrorisError deprecation --- doc/api/util.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/doc/api/util.md b/doc/api/util.md index d75f4491f99557..657abc6ff0649a 100644 --- a/doc/api/util.md +++ b/doc/api/util.md @@ -3324,6 +3324,9 @@ deprecated: REPLACEME > Stability: 0 - Deprecated: Use [`Error.isError`][] instead. +**Note:** As of Node.js v24, `Error.isError()` is currently slower than `util.types.isNativeError()`. +If performance is critical, consider benchmarking both in your environment. + * `value` {any} * Returns: {boolean}