Skip to content

Commit 73a7a78

Browse files
committed
Fix command using shared context
1 parent aa68796 commit 73a7a78

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

agent/agentscripts/agentscripts.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,12 +151,13 @@ func (r *Runner) run(ctx context.Context, script codersdk.WorkspaceAgentScript)
151151
}()
152152

153153
var cmd *exec.Cmd
154+
cmdCtx := ctx
154155
if script.Timeout > 0 {
155156
var ctxCancel context.CancelFunc
156-
ctx, ctxCancel = context.WithTimeout(ctx, script.Timeout)
157+
cmdCtx, ctxCancel = context.WithTimeout(ctx, script.Timeout)
157158
defer ctxCancel()
158159
}
159-
cmdPty, err := r.SSHServer.CreateCommand(ctx, script.Script, nil)
160+
cmdPty, err := r.SSHServer.CreateCommand(cmdCtx, script.Script, nil)
160161
if err != nil {
161162
return xerrors.Errorf("%s script: create command: %w", logPath, err)
162163
}

0 commit comments

Comments
 (0)