@@ -96,6 +96,10 @@ const {
9696 globalThis,
9797} = primordials ;
9898
99+ const {
100+ isProxy,
101+ } = require ( 'internal/util/types' ) ;
102+
99103const { BuiltinModule } = require ( 'internal/bootstrap/realm' ) ;
100104const {
101105 makeRequireFunction,
@@ -1640,29 +1644,28 @@ async function includesProxiesOrGetters(fullExpr, evalFn, context) {
16401644 let currentExpr = '' ;
16411645 for ( let i = 0 ; i < bits . length - 1 ; i ++ ) {
16421646 currentExpr += `${ i === 0 ? '' : '.' } ${ bits [ i ] } ` ;
1643- const currentExprIsObject = await evalPromisified ( `try { ${ currentExpr } !== null && typeof ${ currentExpr } === 'object' } catch { false }` ) ;
1644- if ( ! currentExprIsObject ) {
1645- return false ;
1646- }
1647+ const currentResult = await new Promise ( ( resolve ) =>
1648+ evalFn ( `try { ${ currentExpr } } catch { }` , context , getREPLResourceName ( ) , ( _ , currentObj ) => {
1649+ if ( typeof currentObj !== 'object' || currentObj === null ) {
1650+ return resolve ( false ) ;
1651+ }
16471652
1648- const currentExprIsProxy = await evalPromisified ( `require("node:util/types").isProxy(${ currentExpr } )` ) ;
1649- if ( currentExprIsProxy ) {
1650- return true ;
1651- }
1653+ if ( isProxy ( currentObj ) ) {
1654+ return resolve ( true ) ;
1655+ }
16521656
1653- const typeOfNextBitGet = await evalPromisified ( `typeof Object.getOwnPropertyDescriptor(${ currentExpr } , '${ bits [ i + 1 ] } ')?.get` ) ;
1654- const nextBitHasGetter = typeOfNextBitGet === 'function' ;
1655- if ( nextBitHasGetter ) {
1656- return true ;
1657- }
1658- }
1657+ const nextBitHasGetter = typeof ObjectGetOwnPropertyDescriptor ( currentObj , bits [ i + 1 ] ) ?. get === 'function' ;
1658+ if ( nextBitHasGetter ) {
1659+ return resolve ( true ) ;
1660+ }
16591661
1660- function evalPromisified ( evalExpr ) {
1661- return new Promise ( ( resolve , reject ) =>
1662- evalFn ( evalExpr , context , getREPLResourceName ( ) , ( _ , res ) => {
1663- resolve ( res ) ;
1662+ return resolve ( ) ;
16641663 } ) ) ;
1664+ if ( currentResult !== undefined ) {
1665+ return currentResult ;
1666+ }
16651667 }
1668+ return false ;
16661669}
16671670
16681671REPLServer . prototype . completeOnEditorMode = ( callback ) => ( err , results ) => {
0 commit comments