Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0d86dca

Browse files
authored
fix(codersdk): abort in-progress writes/reads when closing websocket (#12650)
Fixes#9203Related#12065Also, adds some basic tracing infrastructure that we can build upon for more improvements.
1 parent92aa1eb commit0d86dca

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

‎cli/root.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import (
1818
"os/signal"
1919
"path/filepath"
2020
"runtime"
21+
"runtime/trace"
2122
"strings"
2223
"syscall"
2324
"text/tabwriter"
@@ -139,6 +140,22 @@ func (r *RootCmd) AGPL() []*serpent.Command {
139140

140141
// Main is the entrypoint for the Coder CLI.
141142
func (r*RootCmd)RunMain(subcommands []*serpent.Command) {
143+
// This configuration is not available as a standard option because we
144+
// want to trace the entire program, including Options parsing.
145+
goTraceFilePath,ok:=os.LookupEnv("CODER_GO_TRACE")
146+
ifok {
147+
traceFile,err:=os.OpenFile(goTraceFilePath,os.O_CREATE|os.O_TRUNC|os.O_WRONLY,0o644)
148+
iferr!=nil {
149+
panic(fmt.Sprintf("failed to open trace file: %v",err))
150+
}
151+
defertraceFile.Close()
152+
153+
iferr:=trace.Start(traceFile);err!=nil {
154+
panic(fmt.Sprintf("failed to start trace: %v",err))
155+
}
156+
defertrace.Stop()
157+
}
158+
142159
rand.Seed(time.Now().UnixMicro())
143160

144161
cmd,err:=r.Command(subcommands)

‎codersdk/websocket.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ func (c *wsNetConn) Write(b []byte) (n int, err error) {
3232
}
3333

3434
func (c*wsNetConn)Close()error {
35-
deferc.cancel()
35+
c.cancel()
3636
returnc.Conn.Close()
3737
}
3838

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp