From 9276a1d281f31c3a19b7a0366aa0d83f1ab7a68d Mon Sep 17 00:00:00 2001 From: Daniel Cole <71245136+danielcoleAL@users.noreply.github.com> Date: Wed, 24 Apr 2024 14:58:44 +0100 Subject: [PATCH] add timeout for signalflow metadata request (#41) --- internal/job_runner.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/internal/job_runner.go b/internal/job_runner.go index 201f3e6..56c4019 100644 --- a/internal/job_runner.go +++ b/internal/job_runner.go @@ -108,7 +108,9 @@ func (jr *SignalFlowJobRunner) ReplaceOrStartJob(ctx context.Context, program st // Wait for the handle to come through before sending the message to block // the loop less. - handle, err := comp.Handle(ctx) + ctxWithTimeout, cancel := context.WithTimeout(ctx, jr.MetadataTimeout) + handle, err := comp.Handle(ctxWithTimeout) + cancel() if err != nil { // It's possible that the job has already started but the server was delayed sending the handle // to avoid leaking jobs, issue delete using the channel name, ie: detach.