From 4e0ac15fe045012a2398690fefefff66c86d43a7 Mon Sep 17 00:00:00 2001 From: Jose Garcia Date: Wed, 22 Sep 2021 15:10:47 -0400 Subject: [PATCH] Add buffer to channels to avoid goroutine leak --- cmd/ghcs/create.go | 4 ++-- cmd/ghcs/ports.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cmd/ghcs/create.go b/cmd/ghcs/create.go index 45aa794e6..b52690d1d 100644 --- a/cmd/ghcs/create.go +++ b/cmd/ghcs/create.go @@ -172,7 +172,7 @@ type getUserResult struct { // getUser fetches the user record associated with the GITHUB_TOKEN func getUser(ctx context.Context, apiClient *api.API) <-chan getUserResult { - ch := make(chan getUserResult) + ch := make(chan getUserResult, 1) go func() { user, err := apiClient.GetUser(ctx) ch <- getUserResult{user, err} @@ -187,7 +187,7 @@ type locationResult struct { // getLocation fetches the closest Codespace datacenter region/location to the user. func getLocation(ctx context.Context, apiClient *api.API) <-chan locationResult { - ch := make(chan locationResult) + ch := make(chan locationResult, 1) go func() { location, err := apiClient.GetCodespaceRegionLocation(ctx) ch <- locationResult{location, err} diff --git a/cmd/ghcs/ports.go b/cmd/ghcs/ports.go index aeecf0a07..8a4f855fa 100644 --- a/cmd/ghcs/ports.go +++ b/cmd/ghcs/ports.go @@ -123,7 +123,7 @@ type portAttribute struct { } func getDevContainer(ctx context.Context, apiClient *api.API, codespace *api.Codespace) <-chan devContainerResult { - ch := make(chan devContainerResult) + ch := make(chan devContainerResult, 1) go func() { contents, err := apiClient.GetCodespaceRepositoryContents(ctx, codespace, ".devcontainer/devcontainer.json") if err != nil {