mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-15 20:44:01 +02:00
Fix panic with debug.Dump with Page when running the server
This replaces the current implementation with `json.MarshalIndent` which doesn't produce the same output, but at least it doesn't crash. There's a bug in the upstream `litter` library. This can probably be fixed, but that needs to wait. I have tested `go-spew` which does not crash, but it is very data racy in this context. FIxes #12309
This commit is contained in:
@@ -15,12 +15,12 @@
|
||||
package debug
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"sort"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/bep/logg"
|
||||
"github.com/sanity-io/litter"
|
||||
"github.com/spf13/cast"
|
||||
"github.com/yuin/goldmark/util"
|
||||
|
||||
@@ -108,7 +108,11 @@ type Namespace struct {
|
||||
// Also note that the output from Dump may change from Hugo version to the next,
|
||||
// so don't depend on a specific output.
|
||||
func (ns *Namespace) Dump(val any) string {
|
||||
return litter.Sdump(val)
|
||||
b, err := json.MarshalIndent(val, "", " ")
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
return string(b)
|
||||
}
|
||||
|
||||
// VisualizeSpaces returns a string with spaces replaced by a visible string.
|
||||
|
Reference in New Issue
Block a user