From ce6ce766265714553035d328a9be4f313c63e5fd Mon Sep 17 00:00:00 2001 From: Robert Findley Date: Fri, 15 Jul 2022 11:11:52 -0400 Subject: [PATCH] internal/lsp/regtest: increase the time allowed for shutdown Now that we await ongoing work during shutdown, we are seeing regtest flakes simply due to outstanding go command invocations. Allow more time for cleanup. If this is insufficient, we can be more aggressive about terminating go command processes when context is cancelled. For golang/go#53820 Change-Id: I3df3c5510dae34cb14a6efeb02c2963a71e64f3a Reviewed-on: https://go-review.googlesource.com/c/tools/+/417583 gopls-CI: kokoro TryBot-Result: Gopher Robot Reviewed-by: Dylan Le Run-TryBot: Robert Findley --- internal/lsp/regtest/runner.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/internal/lsp/regtest/runner.go b/internal/lsp/regtest/runner.go index 0640e452fb..b2992e9939 100644 --- a/internal/lsp/regtest/runner.go +++ b/internal/lsp/regtest/runner.go @@ -341,9 +341,13 @@ func (r *Runner) Run(t *testing.T, files string, test TestFunc, opts ...RunOptio } // For tests that failed due to a timeout, don't fail to shutdown // because ctx is done. - closeCtx, cancel := context.WithTimeout(xcontext.Detach(ctx), 5*time.Second) + // + // golang/go#53820: now that we await the completion of ongoing work in + // shutdown, we must allow a significant amount of time for ongoing go + // command invocations to exit. + ctx, cancel := context.WithTimeout(xcontext.Detach(ctx), 30*time.Second) defer cancel() - if err := env.Editor.Close(closeCtx); err != nil { + if err := env.Editor.Close(ctx); err != nil { pprof.Lookup("goroutine").WriteTo(os.Stderr, 1) t.Errorf("closing editor: %v", err) }