@@ -80,7 +80,7 @@ function onUncaughtException(error) {
8080 } ) ;
8181}
8282
83- function onMessage ( message ) {
83+ async function onMessage ( message ) {
8484 log ( "RECEIVED:" , message ) ;
8585
8686 var action = message [ 0 ] ;
@@ -97,11 +97,11 @@ function onMessage(message) {
9797 captureGlobalContext ( context ) ;
9898
9999 if ( action === "getAllPropertyNames" ) {
100- onNameRequest ( code , context ) ;
100+ await onNameRequest ( code , context ) ;
101101 } else if ( action === "inspect" ) {
102- onInspectRequest ( code , context ) ;
102+ await onInspectRequest ( code , context ) ;
103103 } else if ( action === "run" ) {
104- onRunRequest ( code , context ) ;
104+ await onRunRequest ( code , context ) ;
105105 } else if ( action === "reply" ) {
106106 onReply ( message , context ) ;
107107 } else {
@@ -118,26 +118,26 @@ function onReply(message, context) {
118118 context . requester . receive ( requestId , reply ) ;
119119}
120120
121- function onNameRequest ( code , context ) {
121+ async function onNameRequest ( code , context ) {
122122 var message = {
123123 id : context . id ,
124- names : getAllPropertyNames ( run ( code ) ) ,
124+ names : getAllPropertyNames ( await run ( code ) ) ,
125125 end : true ,
126126 } ;
127127 context . send ( message ) ;
128128}
129129
130- function onInspectRequest ( code , context ) {
130+ async function onInspectRequest ( code , context ) {
131131 var message = {
132132 id : context . id ,
133- inspection : inspect ( run ( code ) ) ,
133+ inspection : inspect ( await run ( code ) ) ,
134134 end : true ,
135135 } ;
136136 context . send ( message ) ;
137137}
138138
139- function onRunRequest ( code , context ) {
140- var result = run ( code ) ;
139+ async function onRunRequest ( code , context ) {
140+ var result = await run ( code ) ;
141141
142142 // If a result has already been sent, do not send this result.
143143 if ( context . _done ) {
@@ -292,6 +292,6 @@ function inspect(object) {
292292 }
293293}
294294
295- function run ( code ) {
296- return vm . runInThisContext ( code ) ;
295+ async function run ( code ) {
296+ return await vm . runInThisContext ( code , { importModuleDynamically : vm . constants . USE_MAIN_CONTEXT_DEFAULT_LOADER } ) ;
297297}
0 commit comments