@@ -488,7 +488,23 @@ function formatValue(ctx, value, recurseTimes) {
488488 if ( ctx . showHidden ) {
489489 keys = Object . getOwnPropertyNames ( value ) ;
490490 } else {
491- keys = Object . keys ( value ) ;
491+ // This might throw if `value` is a Module Namespace Object from an
492+ // unevaluated module, but we don't want to perform the actual type
493+ // check because it's expensive.
494+ // TODO(devsnek): track https://github.com/tc39/ecma262/issues/1209
495+ // and modify this logic as needed.
496+ try {
497+ keys = Object . keys ( value ) ;
498+ } catch ( err ) {
499+ if ( types . isNativeError ( err ) &&
500+ err . name === 'ReferenceError' &&
501+ types . isModuleNamespaceObject ( value ) ) {
502+ keys = Object . getOwnPropertyNames ( value ) ;
503+ } else {
504+ throw err ;
505+ }
506+ }
507+
492508 if ( symbols . length !== 0 )
493509 symbols = symbols . filter ( ( key ) => propertyIsEnumerable . call ( value , key ) ) ;
494510 }
@@ -782,7 +798,7 @@ function formatNamespaceObject(ctx, value, recurseTimes, keys) {
782798 try {
783799 output [ i ] = formatProperty ( ctx , value , recurseTimes , keys [ i ] , 0 ) ;
784800 } catch ( err ) {
785- if ( ! ( err instanceof ReferenceError ) ) {
801+ if ( ! ( types . isNativeError ( err ) && err . name === ' ReferenceError' ) ) {
786802 throw err ;
787803 }
788804 // Use the existing functionality. This makes sure the indentation and
0 commit comments