@@ -126,10 +126,13 @@ use model::{
126126 types:: FileStorageEntry ,
127127 FileStorageId ,
128128 } ,
129- modules:: module_versions:: {
130- AnalyzedModule ,
131- ModuleSource ,
132- SourceMap ,
129+ modules:: {
130+ module_versions:: {
131+ AnalyzedModule ,
132+ ModuleSource ,
133+ SourceMap ,
134+ } ,
135+ ModuleModel ,
133136 } ,
134137 scheduled_jobs:: VirtualSchedulerModel ,
135138 session_requests:: {
@@ -1189,16 +1192,15 @@ impl<RT: Runtime> ApplicationFunctionRunner<RT> {
11891192 let udf_server_version = path_and_args. npm_version ( ) . clone ( ) ;
11901193 // We should not be missing the module given we validated the path above
11911194 // which requires the module to exist.
1192- let module_version = self
1193- . module_cache
1194- . get_module ( & mut tx, name. module ( ) . clone ( ) )
1195+ let module = ModuleModel :: new ( & mut tx)
1196+ . get_metadata ( name. module ( ) . clone ( ) )
11951197 . await ?
1196- . context ( "Missing a valid module_version " ) ?;
1198+ . context ( "Missing a valid module " ) ?;
11971199 let ( log_line_sender, log_line_receiver) = mpsc:: unbounded ( ) ;
11981200
11991201 let inert_identity = tx. inert_identity ( ) ;
1200- let timer = function_total_timer ( module_version . environment , UdfType :: Action ) ;
1201- let completion_result = match module_version . environment {
1202+ let timer = function_total_timer ( module . environment , UdfType :: Action ) ;
1203+ let completion_result = match module . environment {
12021204 ModuleEnvironment :: Isolate => {
12031205 // TODO: This is the only use case of clone. We should get rid of clone,
12041206 // when we deprecate that codepath.
@@ -1215,7 +1217,7 @@ impl<RT: Runtime> ApplicationFunctionRunner<RT> {
12151217 unix_timestamp,
12161218 context. clone ( ) ,
12171219 vec ! [ log_line] . into ( ) ,
1218- module_version . environment ,
1220+ module . environment ,
12191221 )
12201222 } ,
12211223 )
@@ -1236,6 +1238,13 @@ impl<RT: Runtime> ApplicationFunctionRunner<RT> {
12361238 } )
12371239 } ,
12381240 ModuleEnvironment :: Node => {
1241+ // We should not be missing the module given we validated the path above
1242+ // which requires the module to exist.
1243+ let module_version = self
1244+ . module_cache
1245+ . get_module ( & mut tx, name. module ( ) . clone ( ) )
1246+ . await ?
1247+ . context ( "Missing a valid module_version" ) ?;
12391248 let _request_guard = self
12401249 . node_action_limiter
12411250 . acquire_permit_with_timeout ( & self . runtime )
@@ -1245,7 +1254,7 @@ impl<RT: Runtime> ApplicationFunctionRunner<RT> {
12451254 source_maps. insert ( name. module ( ) . clone ( ) , source_map) ;
12461255 }
12471256
1248- let source_package_id = module_version . source_package_id . ok_or_else ( || {
1257+ let source_package_id = module . source_package_id . ok_or_else ( || {
12491258 anyhow:: anyhow!( "Source package is required to execute actions" )
12501259 } ) ?;
12511260 let source_package = SourcePackageModel :: new ( & mut tx)
@@ -1320,7 +1329,7 @@ impl<RT: Runtime> ApplicationFunctionRunner<RT> {
13201329 unix_timestamp,
13211330 context. clone ( ) ,
13221331 vec ! [ log_line] . into ( ) ,
1323- module_version . environment ,
1332+ module . environment ,
13241333 )
13251334 } ,
13261335 )
@@ -1366,8 +1375,8 @@ impl<RT: Runtime> ApplicationFunctionRunner<RT> {
13661375 Ok ( ActionCompletion {
13671376 outcome,
13681377 execution_time : start. elapsed ( ) ,
1369- environment : module_version . environment ,
1370- memory_in_mb : match module_version . environment {
1378+ environment : module . environment ,
1379+ memory_in_mb : match module . environment {
13711380 ModuleEnvironment :: Isolate => ( * ISOLATE_MAX_USER_HEAP_SIZE / ( 1 << 20 ) )
13721381 . try_into ( )
13731382 . unwrap ( ) ,
@@ -2017,7 +2026,6 @@ impl<RT: Runtime> ActionCallbacks for ApplicationFunctionRunner<RT> {
20172026 // Scheduling from actions is not transaction and happens at latest
20182027 // timestamp.
20192028 self . database . runtime ( ) . unix_timestamp ( ) ,
2020- & self . module_cache ,
20212029 & mut tx,
20222030 )
20232031 . await ?;
0 commit comments