Summary
When building any program that imports net/http for TinyGo's wasm target (i.e. js && wasm build constraints), compilation fails because http/roundtrip_js.go calls t.roundTrip(req) on *Transport, but http/transport.go declares Transport as an empty stub (type Transport struct{}) with no roundTrip method.
Affected versions
- TinyGo 0.41.0 (released 2026-04-21)
- TinyGo 0.41.1 (released 2026-04-22)
TinyGo 0.40.1 is unaffected.
Reproduction
// main.go
package main
import _ "net/http"
func main() {}
go mod init repro
tinygo build -target wasm -o app.wasm .
Actual output
# net/http
$TINYGO_ROOT/src/net/http/roundtrip_js.go:73:12: t.roundTrip undefined (type *Transport has no field or method roundTrip, but does have method RoundTrip)
Root cause
PR #42 ("Add Transporter for wasm js target", commit b2d3a2b, merged 2026-04-17) backported roundtrip_js.go from upstream Go. In upstream Go 1.26.x, *Transport has a private roundTrip method declared in transport.go, and roundtrip_js.go falls back to it when jsFetchMissing || jsFetchDisabled:
https://github.com/tinygo-org/net/blob/master/http/roundtrip_js.go#L72-L74
if jsFetchMissing || jsFetchDisabled {
return t.roundTrip(req)
}
But TinyGo intentionally keeps transport.go as a minimal stub:
https://github.com/tinygo-org/net/blob/master/http/transport.go#L25
The private roundTrip method was not backported, so the fallback call at roundtrip_js.go:73 does not type-check.
Suggested fixes
Either:
- Add a stub
roundTrip method on *Transport in transport.go (or a new _js.go variant) that returns an error like the unsupported-target wrappers elsewhere in TinyGo, or
- Remove the
jsFetchMissing || jsFetchDisabled fallback path from roundtrip_js.go since the empty Transport cannot perform a real round-trip anyway, and simply return an error in that branch.
Impact
This blocks the entire wasm target for any program that depends on net/http (directly or transitively, e.g. via github.com/syumai/workers for Cloudflare Workers).
Summary
When building any program that imports
net/httpfor TinyGo'swasmtarget (i.e.js && wasmbuild constraints), compilation fails becausehttp/roundtrip_js.gocallst.roundTrip(req)on*Transport, buthttp/transport.godeclaresTransportas an empty stub (type Transport struct{}) with noroundTripmethod.Affected versions
TinyGo 0.40.1 is unaffected.
Reproduction
go mod init repro tinygo build -target wasm -o app.wasm .Actual output
Root cause
PR #42 ("Add Transporter for wasm js target", commit b2d3a2b, merged 2026-04-17) backported
roundtrip_js.gofrom upstream Go. In upstream Go 1.26.x,*Transporthas a privateroundTripmethod declared intransport.go, androundtrip_js.gofalls back to it whenjsFetchMissing || jsFetchDisabled:https://github.com/tinygo-org/net/blob/master/http/roundtrip_js.go#L72-L74
But TinyGo intentionally keeps
transport.goas a minimal stub:https://github.com/tinygo-org/net/blob/master/http/transport.go#L25
The private
roundTripmethod was not backported, so the fallback call atroundtrip_js.go:73does not type-check.Suggested fixes
Either:
roundTripmethod on*Transportintransport.go(or a new_js.govariant) that returns an error like the unsupported-target wrappers elsewhere in TinyGo, orjsFetchMissing || jsFetchDisabledfallback path fromroundtrip_js.gosince the emptyTransportcannot perform a real round-trip anyway, and simply return an error in that branch.Impact
This blocks the entire
wasmtarget for any program that depends onnet/http(directly or transitively, e.g. viagithub.com/syumai/workersfor Cloudflare Workers).