JanDeDobbeleer/oh-my-posh · info

the wasm build renders from data only and cannot make reques

Error message

the wasm build renders from data only and cannot make requests

What it means

In WASM builds, runtime/http uses a stubClient whose Do always returns errNoNetwork: the browser entrypoint runs in DataOnly mode, and shipping a real HTTP/TLS/DNS stack would add ~3MB to the module. Any segment or code path attempting an actual HTTP request under WASM gets this error.

Source

Thrown at src/runtime/http/client_js.go:19

//go:build js && wasm

//revive:disable:var-naming // package intentionally mirrors standard name for compatibility across runtime
package http

import (
	"errors"
	"net/http"
)

// The wasm build renders a config from recorded data and never reaches the network: every caller
// of this client goes through runtime.Terminal.HTTPRequest, which already refuses when
// runtime.Flags.DataOnly is set - the only mode the browser entrypoint (src/wasm/main.go) runs in.
//
// Constructing a real http.Transport anyway is what pulls the whole transport, TLS, HTTP/2 and DNS
// stack into the module: measured at 3.26 MB raw, 0.46 MB brotli, for code no visitor can execute.
// A stub that refuses keeps the package's API identical - every segment still compiles unchanged -
// while letting the linker drop all of it.
var errNoNetwork = errors.New("the wasm build renders from data only and cannot make requests")

type stubClient struct{}

func (stubClient) Do(_ *http.Request) (*http.Response, error) {
	return nil, errNoNetwork
}

func init() {
	HTTPClient = stubClient{}
}

View on GitHub (pinned to 0976794618)

Solutions

  1. Enable DataOnly mode so segments render from pre-supplied data instead of making requests (as src/wasm/main.go does)
  2. Remove or disable network-dependent segments in the wasm configuration
  3. Supply the needed data through the provided data channel rather than fetching it in-browser
  4. If network access is truly required, run outside wasm (native binary) instead

Example fix

// before (wasm main)
// segment with URL fetch enabled
// after
flags.DataOnly = true // render from data only; disable network segments
Defensive patterns

Strategy: try-catch

Validate before calling

if runtime.GOOS == "js" && !flags.DataOnly {
  // network segments will fail under wasm; disable them or set DataOnly
}

Type guard

func isWasmNoNetwork(err error) bool { return errors.Is(err, errNoNetwork) }

Try / catch

resp, err := client.Do(req)
if err != nil {
  if errors.Is(err, errNoNetwork) { return cachedData, nil } // wasm fallback
  return nil, err
}

Prevention

When it happens

Trigger: Any http request issued through runtime.http.Client.Do in a wasm build not configured with runtime.Flags.DataOnly, e.g. a segment fetching remote data at prompt-render time in the browser.

Common situations: Embedding oh-my-posh as a wasm prompt renderer and enabling a segment that polls an API (spotify, weather, etc.); calling env.HTTPClient directly from custom wasm code.

Related errors


AI-assisted analysis of JanDeDobbeleer/oh-my-posh@0976794618 (2026-08-31). Data as JSON: /api/errors/1c56d407b4a789f0. Report an issue: GitHub.