Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c350cd1

Browse files
Maisem Alimaisem
authored andcommitted
ssh/tailssh: use background context for uploading recordings
Otherwise we see errors like ``` ssh-session(sess-20230322T005655-5562985593): recording: error sending recording to <addr>:80: Post "http://<addr>:80/record": context canceled ``` The ss.ctx is closed when the session closes, but we don't want to break the upload at that time. Instead we want to wait for the session to close the writer when it finishes, which it is already doing. Updates tailscale/corp#9967 Signed-off-by: Maisem Ali <[email protected]>
1 parent f13b8bf commit c350cd1

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

ssh/tailssh/tailssh.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1343,7 +1343,12 @@ func (ss *sshSession) startNewRecording() (_ *recording, err error) {
13431343
}
13441344

13451345
pr, pw := io.Pipe()
1346-
req, err := http.NewRequestWithContext(ss.ctx, "POST", fmt.Sprintf("http://%s:%d/record", recorder.Addr(), recorder.Port()), pr)
1346+
1347+
// We want to use a background context for uploading and not ss.ctx.
1348+
// ss.ctx is closed when the session closes, but we don't want to break the upload at that time.
1349+
// Instead we want to wait for the session to close the writer when it finishes.
1350+
ctx := context.Background()
1351+
req, err := http.NewRequestWithContext(ctx, "POST", fmt.Sprintf("http://%s:%d/record", recorder.Addr(), recorder.Port()), pr)
13471352
if err != nil {
13481353
pr.Close()
13491354
pw.Close()

0 commit comments

Comments
 (0)