InodeLabs/fern
1
14
Fork
You've already forked fern
2

Fern panics #16

Closed
opened 2026年05月05日 12:38:27 +02:00 by zyga · 6 comments
Contributor
Copy link

Describe the bug

Fern panicked as I was about to edit a note

To Reproduce

Unknown

Expected behavior

Fern should recover from panics and perhaps restart the tui?

Screenshots

Caught panic:
runtime error: index out of range [44] with length 44
Restoring terminal...
goroutine 1 [running]:
runtime/debug.Stack()
	/snap/go/11127/src/runtime/debug/stack.go:26 +0x5e
runtime/debug.PrintStack()
	/snap/go/11127/src/runtime/debug/stack.go:18 +0x13
github.com/charmbracelet/bubbletea.(*Program).recoverFromPanic(0x146deef763c0, {0xe63260, 0x146deef2d908})
	/root/go/pkg/mod/github.com/charmbracelet/bubbletea@v1.3.10/tea.go:847 +0xac
github.com/charmbracelet/bubbletea.(*Program).Run.func2()
	/root/go/pkg/mod/github.com/charmbracelet/bubbletea@v1.3.10/tea.go:638 +0x10c
panic({0xe63260?, 0x146deef2d908?})
	/snap/go/11127/src/runtime/panic.go:860 +0x13a
codeberg.org/InodeLabs/fern/internal/tui/viewer.(*Model).syncEditOffset(0x146def982e10, 0x146deedbe008, 0x50)
	/build/fern/parts/fern/build/internal/tui/viewer/render.go:230 +0x40f
codeberg.org/InodeLabs/fern/internal/tui/viewer.Model.handleEnterInInsert({{{{0x146def0712c0, 0x2, 0x2}, {{...}, {...}}, 0x0}, {{0x146def0712e0, 0x2, 0x2}, {{...}, ...}, ...}, ...}, ...}, ...)
	/build/fern/parts/fern/build/internal/tui/viewer/keys.go:154 +0x5ae
codeberg.org/InodeLabs/fern/internal/tui/viewer.Model.handleInsertKeys({{{{0x146def0712c0, 0x2, 0x2}, {{...}, {...}}, 0x0}, {{0x146def0712e0, 0x2, 0x2}, {{...}, ...}, ...}, ...}, ...}, ...)
	/build/fern/parts/fern/build/internal/tui/viewer/keys.go:113 +0x713
codeberg.org/InodeLabs/fern/internal/tui/viewer.Model.Update({{{{0x146def0712c0, 0x2, 0x2}, {{...}, {...}}, 0x0}, {{0x146def0712e0, 0x2, 0x2}, {{...}, ...}, ...}, ...}, ...}, ...)
	/build/fern/parts/fern/build/internal/tui/viewer/keys.go:75 +0x4d8
codeberg.org/InodeLabs/fern/internal/tui.appModel.delegateToPanel({0x146deeeb7188, {0x146deeeb7188, {0x146deed503c0, 0x4, 0x6}, 0x146def201590, {0x146deeeb4588, 0x9, 0x11}, 0x4, ...}, ...}, ...)
	/build/fern/parts/fern/build/internal/tui/app.go:406 +0xf5
codeberg.org/InodeLabs/fern/internal/tui.appModel.handleKeyMsg({0x146deeeb7188, {0x146deeeb7188, {0x146deed503c0, 0x4, 0x6}, 0x146def201590, {0x146deeeb4588, 0x9, 0x11}, 0x4, ...}, ...}, ...)
	/build/fern/parts/fern/build/internal/tui/app_keys.go:47 +0x305
codeberg.org/InodeLabs/fern/internal/tui.appModel.Update({0x146deeeb7188, {0x146deeeb7188, {0x146deed503c0, 0x4, 0x6}, 0x146def201590, {0x146deeeb4588, 0x9, 0x11}, 0x4, ...}, ...}, ...)
	/build/fern/parts/fern/build/internal/tui/app.go:322 +0x265
github.com/charmbracelet/bubbletea.(*Program).eventLoop(0x146deef763c0, {0x1149b80?, 0x146def3be000?}, 0x146def3a95e0)
	/root/go/pkg/mod/github.com/charmbracelet/bubbletea@v1.3.10/tea.go:494 +0x7ce
github.com/charmbracelet/bubbletea.(*Program).Run(0x146deef763c0)
	/root/go/pkg/mod/github.com/charmbracelet/bubbletea@v1.3.10/tea.go:716 +0xae7
codeberg.org/InodeLabs/fern/internal/tui.Run(0xee64be?)
	/build/fern/parts/fern/build/internal/tui/app.go:660 +0x85
main.runTUI({0x0, 0x0})
	/build/fern/parts/fern/build/main.go:84 +0x656
main.Execute()
	/build/fern/parts/fern/build/main.go:37 +0x34e
main.main()
	/build/fern/parts/fern/build/main.go:20 +0x13
Error: program was killed: program experienced a panic

Version info:

Fern snap revision 7 (1.2.0)

Terminal info:

Gnome terminal 50.1

Additional context

N/A

### Describe the bug Fern panicked as I was about to edit a note ### To Reproduce Unknown ### Expected behavior Fern should recover from panics and perhaps restart the tui? ### Screenshots ``` Caught panic: runtime error: index out of range [44] with length 44 Restoring terminal... goroutine 1 [running]: runtime/debug.Stack() /snap/go/11127/src/runtime/debug/stack.go:26 +0x5e runtime/debug.PrintStack() /snap/go/11127/src/runtime/debug/stack.go:18 +0x13 github.com/charmbracelet/bubbletea.(*Program).recoverFromPanic(0x146deef763c0, {0xe63260, 0x146deef2d908}) /root/go/pkg/mod/github.com/charmbracelet/bubbletea@v1.3.10/tea.go:847 +0xac github.com/charmbracelet/bubbletea.(*Program).Run.func2() /root/go/pkg/mod/github.com/charmbracelet/bubbletea@v1.3.10/tea.go:638 +0x10c panic({0xe63260?, 0x146deef2d908?}) /snap/go/11127/src/runtime/panic.go:860 +0x13a codeberg.org/InodeLabs/fern/internal/tui/viewer.(*Model).syncEditOffset(0x146def982e10, 0x146deedbe008, 0x50) /build/fern/parts/fern/build/internal/tui/viewer/render.go:230 +0x40f codeberg.org/InodeLabs/fern/internal/tui/viewer.Model.handleEnterInInsert({{{{0x146def0712c0, 0x2, 0x2}, {{...}, {...}}, 0x0}, {{0x146def0712e0, 0x2, 0x2}, {{...}, ...}, ...}, ...}, ...}, ...) /build/fern/parts/fern/build/internal/tui/viewer/keys.go:154 +0x5ae codeberg.org/InodeLabs/fern/internal/tui/viewer.Model.handleInsertKeys({{{{0x146def0712c0, 0x2, 0x2}, {{...}, {...}}, 0x0}, {{0x146def0712e0, 0x2, 0x2}, {{...}, ...}, ...}, ...}, ...}, ...) /build/fern/parts/fern/build/internal/tui/viewer/keys.go:113 +0x713 codeberg.org/InodeLabs/fern/internal/tui/viewer.Model.Update({{{{0x146def0712c0, 0x2, 0x2}, {{...}, {...}}, 0x0}, {{0x146def0712e0, 0x2, 0x2}, {{...}, ...}, ...}, ...}, ...}, ...) /build/fern/parts/fern/build/internal/tui/viewer/keys.go:75 +0x4d8 codeberg.org/InodeLabs/fern/internal/tui.appModel.delegateToPanel({0x146deeeb7188, {0x146deeeb7188, {0x146deed503c0, 0x4, 0x6}, 0x146def201590, {0x146deeeb4588, 0x9, 0x11}, 0x4, ...}, ...}, ...) /build/fern/parts/fern/build/internal/tui/app.go:406 +0xf5 codeberg.org/InodeLabs/fern/internal/tui.appModel.handleKeyMsg({0x146deeeb7188, {0x146deeeb7188, {0x146deed503c0, 0x4, 0x6}, 0x146def201590, {0x146deeeb4588, 0x9, 0x11}, 0x4, ...}, ...}, ...) /build/fern/parts/fern/build/internal/tui/app_keys.go:47 +0x305 codeberg.org/InodeLabs/fern/internal/tui.appModel.Update({0x146deeeb7188, {0x146deeeb7188, {0x146deed503c0, 0x4, 0x6}, 0x146def201590, {0x146deeeb4588, 0x9, 0x11}, 0x4, ...}, ...}, ...) /build/fern/parts/fern/build/internal/tui/app.go:322 +0x265 github.com/charmbracelet/bubbletea.(*Program).eventLoop(0x146deef763c0, {0x1149b80?, 0x146def3be000?}, 0x146def3a95e0) /root/go/pkg/mod/github.com/charmbracelet/bubbletea@v1.3.10/tea.go:494 +0x7ce github.com/charmbracelet/bubbletea.(*Program).Run(0x146deef763c0) /root/go/pkg/mod/github.com/charmbracelet/bubbletea@v1.3.10/tea.go:716 +0xae7 codeberg.org/InodeLabs/fern/internal/tui.Run(0xee64be?) /build/fern/parts/fern/build/internal/tui/app.go:660 +0x85 main.runTUI({0x0, 0x0}) /build/fern/parts/fern/build/main.go:84 +0x656 main.Execute() /build/fern/parts/fern/build/main.go:37 +0x34e main.main() /build/fern/parts/fern/build/main.go:20 +0x13 Error: program was killed: program experienced a panic ``` ### Version info: Fern snap revision 7 (1.2.0) ### Terminal info: Gnome terminal 50.1 ### Additional context N/A

@zyga Thanks for reporting this! This is probably another spot in the code where the viewer's contents are modified directly. When render is called, if the modified contents can exceed the index range. I fixed one such instance earlier last week. Will do another sweep through today to clean up any other direct modification calls to safer alternatives. :)

Also excellent suggestion on panic handling with restart! Much better UX than everything hanging.

@zyga Thanks for reporting this! This is probably another spot in the code where the viewer's contents are modified directly. When render is called, if the modified contents can exceed the index range. I fixed one such instance earlier last week. Will do another sweep through today to clean up any other direct modification calls to safer alternatives. :) Also excellent suggestion on panic handling with restart! Much better UX than everything hanging.

@zyga Should be good in v1.3.4, and the new stack trace dump output added should help figure out better what / where your issue is (if it occurs again). Cheers! :)

@zyga Should be good in [v1.3.4](https://codeberg.org/InodeLabs/fern/releases/tag/v1.3.4), and the new stack trace dump output added should help figure out better what / where your issue is (if it occurs again). Cheers! :)
Author
Contributor
Copy link

Thanks @bugwhisperer! Could you please trigger the launchpad snap build? I think the outage is over now.

This is a long shot because the workflow is github specific, but I recently made a very nice publishing pipeline for snaps from CI for projects using GitHub: https://github.com/zyga/hello-rust/

Perhaps I could interest you in making a codeberg/forgejo conversion? I tried to document this cleanly and explain the design there.

Thanks @bugwhisperer! Could you please trigger the launchpad snap build? I think the outage is over now. This is a long shot because the workflow is github specific, but I recently made a very nice publishing pipeline for snaps from CI for projects using GitHub: https://github.com/zyga/hello-rust/ Perhaps I could interest you in making a codeberg/forgejo conversion? I tried to document this cleanly and explain the design there.
Author
Contributor
Copy link

Note that this depends on being able to use snaps. If forgejo uses containers (please educate me) and not full blown VMs or system containers like LXD or incus, then this will not be easy.

Note that this depends on being able to use snaps. If forgejo uses containers (please educate me) and not full blown VMs or system containers like LXD or incus, then this will not be easy.

@zyga Just waiting for launchpad to pull latest code from the repo and then I'll trigger the build manually (assume there's a bit of a backlog from the earlier outage).

Will check our Woodpecker CI docs to see if we can support. I don't have snapcraft installed locally (no systemd). Not sure if that'll be an issue. Might be able to so it in a VM. I'll take a closer look after finishing lunch.

@zyga Just waiting for launchpad to pull latest code from the repo and then I'll trigger the build manually (assume there's a bit of a backlog from the earlier outage). Will check our Woodpecker CI docs to see if we can support. I don't have snapcraft installed locally (no `systemd`). Not sure if that'll be an issue. Might be able to so it in a VM. I'll take a closer look after finishing lunch.
Author
Contributor
Copy link

Thank you for the consideration. I understand that without systemd this is not easy to run locally. I wonder if that's something woodpecker can do later on so I'll keep an eye out.

Thank you for the consideration. I understand that without systemd this is not easy to run locally. I wonder if that's something woodpecker can do later on so I'll keep an eye out.
Sign in to join this conversation.
No Branch/Tag specified
main
v1.5.6
v1.5.5
v1.5.4
v1.5.3
v1.5.2
v1.5.1
v1.5.0
v1.4.1
v1.4.0
v1.3.9
v1.3.8
v1.3.7
v1.3.6
v1.3.5
v1.3.4
v1.3.3
v1.3.2
v1.3.1
v1.3.0
v1.2.1
v1.2.0
v1.1.0-beta
v1.0.3-beta
v1.0.2-beta
v1.0.1-beta
v1.0.0-beta
v0.9.3
v0.9.2
v0.9.1
v0.9.0
v0.8.3
v0.8.2
v0.8.1
v0.8.0
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
InodeLabs/fern#16
Reference in a new issue
InodeLabs/fern
No description provided.
Delete branch "%!s()"

Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?