http: fix t.roundTrip undefined on js/wasm builds

The js/wasm RoundTrip fallback called t.roundTrip(req), an upstream
Go private method that was never backported to TinyGo's Transport stub.

Replace the call with an explicit error return, since the empty
Transport has no dial capability and cannot perform a fallback
round-trip.

Fixes #52

Signed-off-by: deadprogram <ron@hybridgroup.com>
This commit is contained in:
deadprogram
2026-04-25 16:59:47 +02:00
committed by Ron Evans
parent e54965ed5e
commit 1026408a38
+4 -2
View File
@@ -68,9 +68,11 @@ func (t *Transport) RoundTrip(req *Request) (*Response, error) {
// to fall back on the Fetch API, unless it's not available.
// TINYGO: Dial/DialTLS & DialContext/DialTLSContext are not present in tinygo Transport struct, therefore the
// corresponding if statements were removed
// corresponding if statements were removed.
// TINYGO: t.roundTrip (the private fallback used by upstream Go) is not present in the TinyGo stub
// Transport, so return an error when the Fetch API is unavailable instead of calling it.
if jsFetchMissing || jsFetchDisabled {
return t.roundTrip(req)
return nil, errors.New("net/http: Fetch API is not available and no fallback transport is implemented for js/wasm")
}
ac := js.Global().Get("AbortController")