diff --git a/cmd/wasmcloudd/handler.go b/cmd/wasmcloudd/handler.go index 830eab7..4f066e5 100644 --- a/cmd/wasmcloudd/handler.go +++ b/cmd/wasmcloudd/handler.go @@ -9,6 +9,7 @@ import ( "time" "github.com/go-interpreter/wagon/wasm" + "github.com/golang/snappy" shell "github.com/ipfs/go-ipfs-api" "github.com/rogpeppe/go-internal/txtar" "tulpa.dev/within/wasmcloud/cmd/internal" @@ -213,7 +214,19 @@ func getLogs(w http.ResponseWriter, r *http.Request, u *User) { var result []resultLine for _, elog := range elogs { - arc := txtar.Parse(elog.Data) + decompressed, err := snappy.Decode(nil, elog.Data) + if err != nil { + ln.Error(ctx, err) + result = append(result, resultLine{ + ExecID: elog.RunID, + Comment: "ERROR IN DECOMPRESSING LOG BUNDLE", + Logs: map[string]string{ + "logs.txt": err.Error(), + }, + }) + continue + } + arc := txtar.Parse(decompressed) logs := map[string]string{} for _, file := range arc.Files { @@ -261,10 +274,12 @@ func invokeHandlerSync(w http.ResponseWriter, r *http.Request) { } logData := txtar.Format(&resp.Logs) + compressedLogs := snappy.Encode(nil, logData) + entry := ExecutionLog{ HandlerID: hdlr.ID, RunID: resp.UUID, - Data: logData, + Data: compressedLogs, } err = db.Save(&entry).Error @@ -320,10 +335,11 @@ func invokeHandler(w http.ResponseWriter, r *http.Request) { } data := txtar.Format(&resp.Logs) + compressedLogs := snappy.Encode(nil, data) entry := ExecutionLog{ HandlerID: hdlr.ID, RunID: resp.UUID, - Data: data, + Data: compressedLogs, } err = db.Save(&entry).Error