File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed
packages/cubejs-schema-compiler/src/compiler Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -353,7 +353,14 @@ export class DataSchemaCompiler {
353353 exports [ file . fileName ] = obj ;
354354 } ,
355355 asyncModule : ( fn ) => {
356- asyncModules . push ( fn ) ;
356+ const file = ctxFileStorage . getStore ( ) ;
357+ if ( ! file ) {
358+ throw new Error ( 'No file stored in context' ) ;
359+ }
360+ // We need to run async module code in the context of the original data model file
361+ // where it was defined. So we pass the same file to the async context.
362+ // @see https://nodejs.org/api/async_context.html#class-asynclocalstorage
363+ asyncModules . push ( async ( ) => ctxFileStorage . run ( file , ( ) => fn ( ) ) ) ;
357364 } ,
358365 require : ( extensionName : string ) => {
359366 const file = ctxFileStorage . getStore ( ) ;
You can’t perform that action at this time.
0 commit comments