Commit 1ee5d29c759 for nodejs

commit 1ee5d29c7590e0d82d53a605687f13e0b6510355
Author: Miodrag Obradovic <99922455+Kjubikstronk@users.noreply.github.com>
Date:   Sat Oct 3 11:50:25 2026 +0200

    util: fix inspect indentation of detached DataView

    formatExtraProperties() raised ctx.indentationLvl before reading the
    property. The getters of a detached DataView throw, so the level was
    never lowered again, and the DataView and everything inspected after it
    in the same call ended up indented too far. Read the value first.

    Signed-off-by: Miodrag Obradovic <mck097@gmail.com>
    Assisted-by: a closed-source coding agent
    PR-URL: https://github.com/nodejs/node/pull/66421
    Refs: https://github.com/nodejs/node/pull/60131
    Reviewed-By: Jordan Harband <ljharb@gmail.com>
    Reviewed-By: Luigi Pinca <luigipinca@gmail.com>

diff --git a/lib/internal/util/inspect.js b/lib/internal/util/inspect.js
index cf0a8892f8f..622dab4eae8 100644
--- a/lib/internal/util/inspect.js
+++ b/lib/internal/util/inspect.js
@@ -2545,8 +2545,11 @@ function formatPromise(ctx, value, recurseTimes) {
 }

 function formatExtraProperties(ctx, value, recurseTimes, key, typedArray) {
+  // Read the value before indenting: the getter throws for a detached
+  // DataView, and formatRaw() then retries with a fallback value.
+  const extraValue = value[key];
   ctx.indentationLvl += 2;
-  const str = formatValue(ctx, value[key], recurseTimes, typedArray);
+  const str = formatValue(ctx, extraValue, recurseTimes, typedArray);
   ctx.indentationLvl -= 2;

   // These entries are mainly getters. Should they be formatted like getters?
diff --git a/test/parallel/test-util-inspect.js b/test/parallel/test-util-inspect.js
index 3fc17bc6ae9..4e26661a4b4 100644
--- a/test/parallel/test-util-inspect.js
+++ b/test/parallel/test-util-inspect.js
@@ -217,10 +217,10 @@ assert.doesNotMatch(
   assert.strictEqual(
     util.inspect(dv),
     'DataView {\n' +
-    '      [byteLength]: 0,\n' +
-    '      [byteOffset]: undefined,\n' +
-    '      [buffer]: ArrayBuffer { (detached), [byteLength]: 0 }\n' +
-    '    }',
+    '  [byteLength]: 0,\n' +
+    '  [byteOffset]: undefined,\n' +
+    '  [buffer]: ArrayBuffer { (detached), [byteLength]: 0 }\n' +
+    '}',
   );
 }