Open kate-goldenring opened 6 months ago
possible similar issues here:
https://github.com/fermyon/spin/issues/1259 and https://github.com/tinygo-org/tinygo/issues/3798
initializing a logger instance and using that for logging fixes the issue:
package main
import (
"fmt"
"log"
"net/http"
"os"
spinhttp "github.com/fermyon/spin/sdk/go/v2/http"
)
func init() {
spinhttp.Handle(func(w http.ResponseWriter, r *http.Request) {
logger := log.New(os.Stderr, "", log.LstdFlags)
logger.Println("This will cause an error")
w.Header().Set("Content-Type", "text/plain")
fmt.Fprintln(w, "Hello Fermyon!")
})
}
func main() {}
@rajatjindal @kate-goldenring do we have a handle on if this is an upstream (tinygo) bug or an issue with Spin/wasmtime?
Problem: TinyGo Spin apps that use
log
gets the following runtime error from Wasmtime:Example app:
spin --version
)spin 2.0.1 (1d72f1c 2023-11-10)