{"record":{"id":"1c56d407b4a789f0","repo":"JanDeDobbeleer/oh-my-posh","slug":"the-wasm-build-renders-from-data-only-and-cannot-m","errorCode":null,"errorMessage":"the wasm build renders from data only and cannot make requests","messagePattern":"the wasm build renders from data only and cannot make requests","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"info","filePath":"src/runtime/http/client_js.go","lineNumber":19,"sourceCode":"//go:build js && wasm\n\n//revive:disable:var-naming // package intentionally mirrors standard name for compatibility across runtime\npackage http\n\nimport (\n\t\"errors\"\n\t\"net/http\"\n)\n\n// The wasm build renders a config from recorded data and never reaches the network: every caller\n// of this client goes through runtime.Terminal.HTTPRequest, which already refuses when\n// runtime.Flags.DataOnly is set - the only mode the browser entrypoint (src/wasm/main.go) runs in.\n//\n// Constructing a real http.Transport anyway is what pulls the whole transport, TLS, HTTP/2 and DNS\n// stack into the module: measured at 3.26 MB raw, 0.46 MB brotli, for code no visitor can execute.\n// A stub that refuses keeps the package's API identical - every segment still compiles unchanged -\n// while letting the linker drop all of it.\nvar errNoNetwork = errors.New(\"the wasm build renders from data only and cannot make requests\")\n\ntype stubClient struct{}\n\nfunc (stubClient) Do(_ *http.Request) (*http.Response, error) {\n\treturn nil, errNoNetwork\n}\n\nfunc init() {\n\tHTTPClient = stubClient{}\n}\n","sourceCodeStart":1,"sourceCodeEnd":30,"githubUrl":"https://github.com/JanDeDobbeleer/oh-my-posh/blob/0976794618c5ed95de0985dded50de1b4dc914cb/src/runtime/http/client_js.go#L1-L30","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Enable DataOnly mode so segments render from pre-supplied data instead of making requests (as src/wasm/main.go does)","Remove or disable network-dependent segments in the wasm configuration","Supply the needed data through the provided data channel rather than fetching it in-browser","If network access is truly required, run outside wasm (native binary) instead"],"exampleFix":"// before (wasm main)\n// segment with URL fetch enabled\n// after\nflags.DataOnly = true // render from data only; disable network segments","handlingStrategy":"try-catch","validationCode":"if runtime.GOOS == \"js\" && !flags.DataOnly {\n  // network segments will fail under wasm; disable them or set DataOnly\n}","typeGuard":"func isWasmNoNetwork(err error) bool { return errors.Is(err, errNoNetwork) }","tryCatchPattern":"resp, err := client.Do(req)\nif err != nil {\n  if errors.Is(err, errNoNetwork) { return cachedData, nil } // wasm fallback\n  return nil, err\n}","preventionTips":["Always set DataOnly mode in the wasm entrypoint","Disable URL-fetching segments in wasm configurations","Supply remote data through the data channel instead of in-browser requests"],"tags":["wasm","http","network","stub"],"backgroundTag":"wasm-network-disabled","analyzedSha":"0976794618c5ed95de0985dded50de1b4dc914cb","analyzedAt":"2026-08-31T23:41:19.708Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}