@@ -83,7 +83,8 @@ struct ModuleService::ServiceImpl : viam::module::v1::ModuleService::Service {
8383 } catch (const std::exception& exc) {
8484 return grpc::Status (::grpc::INTERNAL, exc.what ());
8585 }
86- };
86+ }
87+
8788 try {
8889 parent.server_ ->add_resource (res, ctx->deadline ());
8990 } catch (const std::exception& exc) {
@@ -129,16 +130,18 @@ struct ModuleService::ServiceImpl : viam::module::v1::ModuleService::Service {
129130 }
130131
131132 const std::shared_ptr<const ModelRegistration> reg =
132- Registry::get ().lookup_model (cfg.name ());
133+ Registry::get ().lookup_model (cfg.api (), cfg. model ());
133134
134- // TODO RSDK-11067 new resource gets constructed while old one is still alive.
135- if (reg) {
136- try {
137- const std::shared_ptr<Resource> resource = reg->construct_resource (deps, cfg);
138- manager->replace_one (cfg.resource_name (), resource);
139- } catch (const std::exception& exc) {
140- return grpc::Status (::grpc::INTERNAL, exc.what ());
141- }
135+ if (!reg) {
136+ return grpc::Status (::grpc::INTERNAL,
137+ " Unable to rebuild resource: model registration not found" );
138+ }
139+
140+ try {
141+ std::shared_ptr<Resource> resource = reg->construct_resource (deps, cfg);
142+ manager->replace_one (cfg.resource_name (), std::move (resource));
143+ } catch (const std::exception& exc) {
144+ return grpc::Status (::grpc::INTERNAL, exc.what ());
142145 }
143146
144147 return grpc::Status ();
0 commit comments