You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
dbc sync can take time, especially if the user is on a slow connection, and it can't be interrupted with the usual SIGINT. I have to resort to SIGKILL. Ideally every dbc subcommand can be Ctrl+C'd.
To reproduce, I'm using a network metering tool on my machine to simulate a 3G connection in order to give myself enough time to try Ctrl+C'ing. I then dbc added every driver (one would be enough) and ran dbc sync. I then try Ctrl+C (no change) and also kill $PID (also no change). Finally, kill -9 $PID ends the process.
Hmm. Ctrl+C seems to work just fine for me when running dbc sync. We define the handling for Ctrl+C in baseModel.Update which checks for Ctrl+C/Ctrl+D and Escape. All of those should allow quitting early.
That said, for kill $PID looks like we need to add a handler for tea.InterruptMsg{} in baseModel which we can likely do without issue.
$ dlv attach 11008
Type 'help' for list of commands.
(dlv) bt
0 0x000000019fe454f8 in ???
at ?:-1
1 0x0000000102509418 in runtime.pthread_cond_wait_trampoline
at /opt/homebrew/Cellar/go/1.25.1/libexec/src/runtime/sys_darwin_arm64.s:433
2 0x0000000102507f78 in runtime.asmcgocall
at /opt/homebrew/Cellar/go/1.25.1/libexec/src/runtime/asm_arm64.s:1081
error: protocol error E08 during memory read for packet $mfffffffe91f794d0,8
(truncated)
(dlv)
(dlv) goroutines
Goroutine 1 - User: /Users/bryce/go/pkg/mod/github.com/charmbracelet/[email protected]/tea.go:745 main.downloadPkg.func1 (0x1027a3eb8) [select 504921585037166]
-- >8 --
(dlv) goroutine 1 bt
0 0x0000000102500120 in runtime.gopark
at /opt/homebrew/Cellar/go/1.25.1/libexec/src/runtime/proc.go:461
1 0x00000001024e0d5c in runtime.selectgo
at /opt/homebrew/Cellar/go/1.25.1/libexec/src/runtime/select.go:351
2 0x00000001027a3eb8 in github.com/charmbracelet/bubbletea.(*Program).Send
at /Users/bryce/go/pkg/mod/github.com/charmbracelet/[email protected]/tea.go:745
3 0x00000001027a3eb8 in main.downloadPkg.func1
at ./cmd/dbc/main.go:79
4 0x000000010277f4f0 in github.com/columnar-tech/dbc.(*progressWriter).Write
at ./drivers.go:183
5 0x0000000102534b2c in io.copyBuffer
at /opt/homebrew/Cellar/go/1.25.1/libexec/src/io/io.go:431
6 0x000000010277f8dc in io.Copy
at /opt/homebrew/Cellar/go/1.25.1/libexec/src/io/io.go:388
7 0x000000010277f8dc in github.com/columnar-tech/dbc.PkgInfo.DownloadPackage
at ./drivers.go:229
8 0x000000010279ad74 in main.downloadPkg
at ./cmd/dbc/main.go:78
9 0x00000001027a2614 in main.syncModel.Update.syncModel.installDriver.func7
at ./cmd/dbc/sync.go:245
10 0x00000001025d3e5c in github.com/charmbracelet/bubbletea.(*Program).eventLoop
at /Users/bryce/go/pkg/mod/github.com/charmbracelet/[email protected]/tea.go:478
11 0x00000001025d4c80 in github.com/charmbracelet/bubbletea.(*Program).Run
at /Users/bryce/go/pkg/mod/github.com/charmbracelet/[email protected]/tea.go:686
12 0x000000010279b578 in main.main
at ./cmd/dbc/main.go:167
13 0x00000001024cd4f8 in runtime.main
at /opt/homebrew/Cellar/go/1.25.1/libexec/src/runtime/proc.go:285
14 0x0000000102507fc4 in runtime.goexit
at /opt/homebrew/Cellar/go/1.25.1/libexec/src/runtime/asm_arm64.s:1268
So, I think we've gotten into a deadlock with the bubbletea messages. If I change the modified downloadPkg func to no longer send the progressMsg then everything works. So I think I need to restructure this a bit
Activity
zeroshade commentedon Oct 13, 2025
Hmm. Ctrl+C seems to work just fine for me when running
dbc sync. We define the handling for Ctrl+C inbaseModel.Updatewhich checks for Ctrl+C/Ctrl+D and Escape. All of those should allow quitting early.That said, for
kill $PIDlooks like we need to add a handler fortea.InterruptMsg{}in baseModel which we can likely do without issue.amoeba commentedon Oct 13, 2025
Maybe we're catching Ctrl+C during portions of sync but not all of it? Here's what I see,
amoeba commentedon Oct 13, 2025
Maybe something else is going on. I turned off my network simulator and sync is still stalling.
amoeba commentedon Oct 13, 2025
I'm not sure what to glean from this,
zeroshade commentedon Oct 13, 2025
Hmm, i was able to get it to get stuck too. let me see if i can narrow down the cause
amoeba commentedon Oct 13, 2025
(dlv) goroutines
Goroutine 1 - User: /Users/bryce/go/pkg/mod/github.com/charmbracelet/[email protected]/tea.go:745 main.downloadPkg.func1 (0x1027a3eb8) [select 504921585037166]
-- >8 --
(dlv) goroutine 1 bt
0 0x0000000102500120 in runtime.gopark
at /opt/homebrew/Cellar/go/1.25.1/libexec/src/runtime/proc.go:461
1 0x00000001024e0d5c in runtime.selectgo
at /opt/homebrew/Cellar/go/1.25.1/libexec/src/runtime/select.go:351
2 0x00000001027a3eb8 in github.com/charmbracelet/bubbletea.(*Program).Send
at /Users/bryce/go/pkg/mod/github.com/charmbracelet/[email protected]/tea.go:745
3 0x00000001027a3eb8 in main.downloadPkg.func1
at ./cmd/dbc/main.go:79
4 0x000000010277f4f0 in github.com/columnar-tech/dbc.(*progressWriter).Write
at ./drivers.go:183
5 0x0000000102534b2c in io.copyBuffer
at /opt/homebrew/Cellar/go/1.25.1/libexec/src/io/io.go:431
6 0x000000010277f8dc in io.Copy
at /opt/homebrew/Cellar/go/1.25.1/libexec/src/io/io.go:388
7 0x000000010277f8dc in github.com/columnar-tech/dbc.PkgInfo.DownloadPackage
at ./drivers.go:229
8 0x000000010279ad74 in main.downloadPkg
at ./cmd/dbc/main.go:78
9 0x00000001027a2614 in main.syncModel.Update.syncModel.installDriver.func7
at ./cmd/dbc/sync.go:245
10 0x00000001025d3e5c in github.com/charmbracelet/bubbletea.(*Program).eventLoop
at /Users/bryce/go/pkg/mod/github.com/charmbracelet/[email protected]/tea.go:478
11 0x00000001025d4c80 in github.com/charmbracelet/bubbletea.(*Program).Run
at /Users/bryce/go/pkg/mod/github.com/charmbracelet/[email protected]/tea.go:686
12 0x000000010279b578 in main.main
at ./cmd/dbc/main.go:167
13 0x00000001024cd4f8 in runtime.main
at /opt/homebrew/Cellar/go/1.25.1/libexec/src/runtime/proc.go:285
14 0x0000000102507fc4 in runtime.goexit
at /opt/homebrew/Cellar/go/1.25.1/libexec/src/runtime/asm_arm64.s:1268
zeroshade commentedon Oct 13, 2025
So, I think we've gotten into a deadlock with the bubbletea messages. If I change the modified
downloadPkgfunc to no longer send theprogressMsgthen everything works. So I think I need to restructure this a bitamoeba commentedon Oct 13, 2025
Thanks for investigating.
zeroshade commentedon Oct 13, 2025
put up a PR with a quick fix
fix(sync): fix deadlock during download (#128)
fix(sync): fix deadlock during download (#128)