From 9090afca4a42e1fce762541bdc428b0edaa0a0a4 Mon Sep 17 00:00:00 2001
From: Maxime Vidori <maxime.vidori@gmail.com>
Date: Mon, 10 Jun 2024 09:48:54 +0200
Subject: [PATCH] Fix goroutine leak when reconciling

This patch fixes the propagation of context cancellation through the
call stack. It prevents leaks of channel and goroutine from the
[terraform provider][provider_code].

Closes: #538

[provider_code]: https://github.com/hashicorp/terraform-provider-google/blob/1d1a50adf64af60815b7a08ffc5e9d3e856d2e9c/google/transport/batcher.go#L117-L123

Signed-off-by: Maxime Vidori <maxime.vidori@gmail.com>
---
 internal/clients/gcp.go | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/internal/clients/gcp.go b/internal/clients/gcp.go
index dfabdf87b..e8f0e87ce 100644
--- a/internal/clients/gcp.go
+++ b/internal/clients/gcp.go
@@ -161,7 +161,7 @@ func configureNoForkGCPClient(ctx context.Context, ps *terraform.Setup, p schema
 	// only once and using a pointer argument here will cause
 	// race conditions between resources referring to different
 	// ProviderConfigs.
-	diag := p.Configure(context.WithoutCancel(ctx), &tfsdk.ResourceConfig{
+	diag := p.Configure(ctx, &tfsdk.ResourceConfig{
 		Config: ps.Configuration,
 	})
 	if diag != nil && diag.HasError() {