@@ -478,7 +478,23 @@ function formatValue(ctx, value, recurseTimes) {
478478 if ( ctx . showHidden ) {
479479 keys = Object . getOwnPropertyNames ( value ) ;
480480 } else {
481- keys = Object . keys ( value ) ;
481+ // This might throw if `value` is a Module Namespace Object from an
482+ // unevaluated module, but we don't want to perform the actual type
483+ // check because it's expensive.
484+ // TODO(devsnek): track https://github.com/tc39/ecma262/issues/1209
485+ // and modify this logic as needed.
486+ try {
487+ keys = Object . keys ( value ) ;
488+ } catch ( err ) {
489+ if ( types . isNativeError ( err ) &&
490+ err . name === 'ReferenceError' &&
491+ types . isModuleNamespaceObject ( value ) ) {
492+ keys = Object . getOwnPropertyNames ( value ) ;
493+ } else {
494+ throw err ;
495+ }
496+ }
497+
482498 if ( symbols . length !== 0 )
483499 symbols = symbols . filter ( ( key ) => propertyIsEnumerable . call ( value , key ) ) ;
484500 }
@@ -772,7 +788,7 @@ function formatNamespaceObject(ctx, value, recurseTimes, keys) {
772788 try {
773789 output [ i ] = formatProperty ( ctx , value , recurseTimes , keys [ i ] , 0 ) ;
774790 } catch ( err ) {
775- if ( ! ( err instanceof ReferenceError ) ) {
791+ if ( ! ( types . isNativeError ( err ) && err . name === ' ReferenceError' ) ) {
776792 throw err ;
777793 }
778794 // Use the existing functionality. This makes sure the indentation and
0 commit comments