{"record":{"id":"775b20d009b1d4f0","repo":"denoland/deno","slug":"syntaxerror-775b20","errorCode":"SyntaxError","errorMessage":"e.message","messagePattern":"e\\.message","errorType":"exception","errorClass":"DOMException","httpStatus":null,"severity":"error","filePath":"ext/web/webtransport.js","lineNumber":200,"sourceCode":"    let promise;\n\n    if (url === illegalConstructorKey) {\n      promise = PromiseResolve(options);\n    } else {\n      const prefix = \"Failed to construct 'WebTransport'\";\n      webidl.requiredArguments(arguments.length, 1, prefix);\n      url = webidl.converters.USVString(url, prefix, \"Argument 1\");\n      options = webidl.converters.WebTransportOptions(\n        options,\n        prefix,\n        \"Argument 2\",\n      );\n\n      let parsedURL;\n      try {\n        parsedURL = new URL(url, getLocationHref());\n      } catch (e) {\n        throw new DOMException(e.message, \"SyntaxError\");\n      }\n\n      switch (options.congestionControl) {\n        case \"throughput\":\n          this.#congestionControl = \"throughput\";\n          break;\n        case \"low-latency\":\n          this.#congestionControl = \"low-latency\";\n          break;\n        default:\n          this.#congestionControl = \"default\";\n      }\n      this.#anticipatedConcurrentIncomingBidirectionalStreams =\n        options.anticipatedConcurrentIncomingBidirectionalStreams;\n      this.#anticipatedConcurrentIncomingUnidirectionalStreams =\n        options.anticipatedConcurrentIncomingUnidirectionalStreams;\n\n      promise = PromisePrototypeThen(","sourceCodeStart":182,"sourceCodeEnd":218,"githubUrl":"https://github.com/denoland/deno/blob/9ad36f7a2cce60488e6ec52283efb32efddaf93a/ext/web/webtransport.js#L182-L218","documentation":"The WebTransport constructor parses its URL argument with the standard URL parser (relative to the module's location); if parsing fails, the underlying TypeError's message is rewrapped as a DOMException named SyntaxError in ext/web/webtransport.js. Typical causes: missing or unsupported scheme (only https/http-style absolute URLs parse here), spaces or invalid characters, or a bad port. The failure is synchronous, at `new WebTransport(url)`.","triggerScenarios":"new WebTransport(\"example.com:443\") — missing https:// scheme; URLs with unencoded spaces or invalid port like https://h:abc; building URLs by string concatenation that drops the scheme; relative paths like \"/wt\" which cannot resolve to a ws/wt endpoint.","commonSituations":"Reading the URL from an env var that is empty or lacks the scheme; joining host and path with malformed separators; copying a hostname from a config UI that strips the protocol; trailing whitespace from a config file.","solutions":["Use an absolute URL with scheme and host, e.g. \"https://example.com:443/wt\".","Normalize first: `const u = new URL(raw); u.protocol = \"https:\"; new WebTransport(u.href)`.","Trim whitespace and validate env-provided URLs before constructing.","URL-encode the path components that may contain special characters."],"exampleFix":"// before\nconst wt = new WebTransport(`${HOST}:${PORT}/wt`); // HOST lacks scheme\n\n// after\nconst wt = new WebTransport(`https://${HOST}:${PORT}/wt`);","handlingStrategy":"validation","validationCode":"let parsed;\ntry {\n  parsed = new URL(rawUrl);\n  parsed.protocol = \"https:\";\n} catch {\n  throw new Error(`invalid WebTransport URL: ${rawUrl}`);\n}\nconst wt = new WebTransport(parsed.href);","typeGuard":"function isAbsoluteHttpsUrl(u) {\n  try { return new URL(u).protocol === \"https:\"; } catch { return false; }\n}","tryCatchPattern":"try { const wt = new WebTransport(url); } catch (e) { if (e instanceof DOMException && e.name === \"SyntaxError\") throw new Error(`bad endpoint URL: ${url}`); throw e; }","preventionTips":["Validate env-provided endpoints with new URL() at startup, not at first connect.","Always include the scheme in stored URLs; trim whitespace when loading config.","Centralize endpoint parsing so one helper catches malformed URLs everywhere."],"tags":["webtransport","url-parsing","web-api","domexception","syntaxerror"],"backgroundTag":"invalid-url","analyzedSha":"9ad36f7a2cce60488e6ec52283efb32efddaf93a","analyzedAt":"2026-08-20T13:07:44.778Z","contentChangedAt":"2026-08-20T13:07:44.778Z","schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}