Skip to content

net/http: t.roundTrip undefined on js+wasm build (TinyGo 0.41.0 / 0.41.1) #52

@yuta-yoshinaga

Description

@yuta-yoshinaga

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

type Transport struct{}

The private roundTrip method was not backported, so the fallback call at roundtrip_js.go:73 does not type-check.

Suggested fixes

Either:

  1. 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
  2. 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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions