Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ vendor/
/lint.log
/cover.out
/cover.html
.idea/
5 changes: 3 additions & 2 deletions internal/stack/stacks.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,9 @@ func (p *stackParser) parseStack(line string) (Stack, error) {
// Just skip it.
continue
}
if strings.HasPrefix(line, "...") && strings.HasSuffix(line, " frames elided...") {
// e.g. ...23 frames elided...
trimmedLine := strings.TrimSpace(line)
if strings.HasPrefix(trimmedLine, "...") && strings.HasSuffix(trimmedLine, " frames elided...") {
// e.g. "...23 frames elided..." or " ...23 frames elided..."
// This indicates frames were elided from the stack trace,
// attempting to parse them via parseFuncName will fail resulting in a panic
// and a relatively useless output. Gracefully handle this.
Expand Down
18 changes: 18 additions & 0 deletions internal/stack/stacks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,24 @@ func TestParseStack(t *testing.T) {
"example.com/foo/bar.baz",
},
},
{
name: "elided frames with leading whitespaces",
give: joinLines(
"goroutine 1 [running]:",
"example.com/foo/bar.baz()",
" example.com/foo/bar.go:123",
" ...23 frames elided...",
"created by example.com/foo/bar.qux",
" example.com/foo/bar.go:456",
),
id: 1,
state: "running",
createdBy: "example.com/foo/bar.qux",
firstFunc: "example.com/foo/bar.baz",
funcs: []string{
"example.com/foo/bar.baz",
},
},
}

for _, tt := range tests {
Expand Down
Loading