File tree Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -134,6 +134,9 @@ const builtInObjects = new Set(
134
134
ObjectGetOwnPropertyNames ( global ) . filter ( ( e ) => / ^ [ A - Z ] [ a - z A - Z 0 - 9 ] + $ / . test ( e ) )
135
135
) ;
136
136
137
+ // https://tc39.es/ecma262/#sec-IsHTMLDDA-internal-slot
138
+ const isUndetectableObject = ( v ) => typeof v === 'undefined' && v !== undefined ;
139
+
137
140
// These options must stay in sync with `getUserOptions`. So if any option will
138
141
// be added or removed, `getUserOptions` must also be updated accordingly.
139
142
const inspectDefaultOptions = ObjectSeal ( {
@@ -680,7 +683,9 @@ function findTypedConstructor(value) {
680
683
// value afterwards again.
681
684
function formatValue ( ctx , value , recurseTimes , typedArray ) {
682
685
// Primitive types cannot have properties.
683
- if ( typeof value !== 'object' && typeof value !== 'function' ) {
686
+ if ( typeof value !== 'object' &&
687
+ typeof value !== 'function' &&
688
+ ! isUndetectableObject ( value ) ) {
684
689
return formatPrimitive ( ctx . stylize , value , ctx ) ;
685
690
}
686
691
if ( value === null ) {
Original file line number Diff line number Diff line change @@ -26,6 +26,7 @@ const { internalBinding } = require('internal/test/binding');
26
26
const JSStream = internalBinding ( 'js_stream' ) . JSStream ;
27
27
const util = require ( 'util' ) ;
28
28
const vm = require ( 'vm' ) ;
29
+ const v8 = require ( 'v8' ) ;
29
30
const { previewEntries } = internalBinding ( 'util' ) ;
30
31
const { inspect } = util ;
31
32
const { MessageChannel } = require ( 'worker_threads' ) ;
@@ -2748,3 +2749,11 @@ assert.strictEqual(
2748
2749
assert . deepStrictEqual ( colors . gray , originalValue ) ;
2749
2750
assert . strictEqual ( colors . grey , colors . gray ) ;
2750
2751
}
2752
+
2753
+ // https://github.com/nodejs/node/issues/31889
2754
+ {
2755
+ v8 . setFlagsFromString ( '--allow-natives-syntax' ) ;
2756
+ const undetectable = vm . runInThisContext ( '%GetUndetectable()' ) ;
2757
+ v8 . setFlagsFromString ( '--no-allow-natives-syntax' ) ;
2758
+ assert . strictEqual ( inspect ( undetectable ) , '{}' ) ;
2759
+ }
You can’t perform that action at this time.
0 commit comments