@@ -55,7 +55,7 @@ const {
5555const { signals } = internalBinding ( 'constants' ) . os ;
5656const {
5757 guessHandleType : _guessHandleType ,
58- defineLazyProperties,
58+ defineLazyProperties : _defineLazyProperties ,
5959 privateSymbols : {
6060 arrow_message_private_symbol,
6161 decorated_private_symbol,
@@ -66,6 +66,10 @@ const { isNativeError, isPromise } = internalBinding('types');
6666const { getOptionValue } = require ( 'internal/options' ) ;
6767const assert = require ( 'internal/assert' ) ;
6868const { encodings } = internalBinding ( 'string_decoder' ) ;
69+ const {
70+ isBuildingSnapshot,
71+ addDeserializeCallback,
72+ } = require ( 'internal/v8/startup_snapshot' ) . namespace ;
6973
7074const noCrypto = ! process . versions . openssl ;
7175const noTypeScript = ! process . versions . amaro ;
@@ -611,6 +615,18 @@ function exposeGetterAndSetter(target, name, getter, setter = undefined) {
611615 } ) ;
612616}
613617
618+ function doWhenNotBUildingSnapshot ( fn ) {
619+ if ( isBuildingSnapshot ( ) ) {
620+ addDeserializeCallback ( fn ) ;
621+ } else {
622+ fn ( ) ;
623+ }
624+ }
625+
626+ function defineLazyProperties ( ...args ) {
627+ doWhenNotBUildingSnapshot ( ( ) => ReflectApply ( _defineLazyProperties , this , args ) ) ;
628+ }
629+
614630function defineReplaceableLazyAttribute ( target , id , keys , writable = true , check ) {
615631 let mod ;
616632 for ( let i = 0 ; i < keys . length ; i ++ ) {
@@ -852,6 +868,7 @@ module.exports = {
852868 defineReplaceableLazyAttribute,
853869 deprecate,
854870 deprecateInstantiation,
871+ doWhenNotBUildingSnapshot,
855872 emitExperimentalWarning,
856873 encodingsMap,
857874 exposeInterface,
0 commit comments