diff --git a/plugin/grpc_provider.go b/plugin/grpc_provider.go index 2b88330252..3405505961 100644 --- a/plugin/grpc_provider.go +++ b/plugin/grpc_provider.go @@ -508,7 +508,17 @@ func (p *GRPCProvider) ReadDataSource(r providers.ReadDataSourceRequest) (resp p // closing the grpc connection is final, and terraform will call it at the end of every phase. func (p *GRPCProvider) Close() error { - // check this since it's not automatically inserted during plugin creation + log.Printf("[TRACE] GRPCProvider: PlanResourceChange") + + // close the remote listener if we're running within a test + if p.TestListener != nil { + p.TestListener.Close() + } + + // Check this since it's not automatically inserted during plugin creation. + // It's currently only inserted by the command package, because that is + // where the factory is built and is the only point with access to the + // plugin.Client. if p.PluginClient == nil { log.Println("[DEBUG] provider has no plugin.Client") return nil