{"record":{"id":"4cd107e22f1616ad","repo":"denoland/deno","slug":"incominghighwatermark-cannot-be-negative","errorCode":null,"errorMessage":"incomingHighWaterMark cannot be negative","messagePattern":"incomingHighWaterMark cannot be negative","errorType":"exception","errorClass":"RangeError","httpStatus":null,"severity":"error","filePath":"ext/web/webtransport.js","lineNumber":839,"sourceCode":"      throw new RangeError(\"outgoingMaxAge cannot be negative\");\n    }\n    if (value === 0) value = null;\n    this.#outgoingMaxAge = value;\n  }\n\n  get incomingHighWaterMark() {\n    webidl.assertBranded(this, WebTransportDatagramDuplexStreamPrototype);\n    return this.#incomingHighWaterMark;\n  }\n\n  set incomingHighWaterMark(value) {\n    webidl.assertBranded(this, WebTransportDatagramDuplexStreamPrototype);\n    value = webidl.converters[\"unrestricted double\"](\n      value,\n      \"Failed to execute 'incomingHighWaterMark' on 'WebTransportDatagramDuplexStream'\",\n    );\n    if (value < 0 || NumberIsNaN(value)) {\n      throw new RangeError(\"incomingHighWaterMark cannot be negative\");\n    }\n    if (value < 1) value = 1;\n    this.#incomingHighWaterMark = value;\n  }\n\n  get outgoingHighWaterMark() {\n    webidl.assertBranded(this, WebTransportDatagramDuplexStreamPrototype);\n    return this.#outgoingHighWaterMark;\n  }\n\n  set outgoingHighWaterMark(value) {\n    webidl.assertBranded(this, WebTransportDatagramDuplexStreamPrototype);\n    value = webidl.converters[\"unrestricted double\"](\n      value,\n      \"Failed to execute 'outgoingHighWaterMark' on 'WebTransportDatagramDuplexStream'\",\n    );\n    if (value < 0 || NumberIsNaN(value)) {\n      throw new RangeError(\"outgoingHighWaterMark cannot be negative\");","sourceCodeStart":821,"sourceCodeEnd":857,"githubUrl":"https://github.com/denoland/deno/blob/9ad36f7a2cce60488e6ec52283efb32efddaf93a/ext/web/webtransport.js#L821-L857","documentation":"WebTransportDatagramDuplexStream.incomingHighWaterMark controls backpressure for the readable side of datagram reception. Deno's setter in ext/web/webtransport.js accepts an 'unrestricted double' and throws a RangeError for negative numbers or NaN. Values below 1 (including 0 and fractions) are not errors — they are clamped up to 1.","triggerScenarios":"duplex.incomingHighWaterMark = -5; NaN from an uninitialized variable; configuration piping a '-1 = default' sentinel straight into the setter.","commonSituations":"Size/buffer tuning exposed in config files; unit conversions that yield negative numbers when inputs are swapped; NaN defaults from destructuring with misspelled keys.","solutions":["Assign a positive finite number (bytes/entries as the API defines).","Convert 'unset' sentinels to a sane default like 1 instead of -1.","Validate with Number.isFinite(v) && v >= 0 before assigning.","Note the clamp: anything in [0, 1) becomes 1, so small values are safe."],"exampleFix":"// before\nduplex.incomingHighWaterMark = cfg.hwm ?? -1;\n\n// after\nduplex.incomingHighWaterMark = cfg.hwm ?? 1;","handlingStrategy":"validation","validationCode":"function toHighWaterMark(v, fallback = 1) {\n  return Number.isFinite(v) && v >= 1 ? v : fallback;\n}\nduplex.incomingHighWaterMark = toHighWaterMark(cfg.hwm);","typeGuard":"function isValidHighWaterMark(v) {\n  return typeof v === \"number\" && Number.isFinite(v) && v >= 0;\n}","tryCatchPattern":"try { duplex.incomingHighWaterMark = v; } catch (e) { if (e instanceof RangeError) duplex.incomingHighWaterMark = 1; else throw e; }","preventionTips":["Default buffer sizes to a positive constant, never to -1.","Note values under 1 are clamped to 1 — pick realistic buffer sizes.","Validate numeric tuning knobs once at config load."],"tags":["webtransport","datagrams","backpressure","validation","rangeerror"],"backgroundTag":"negative-value-rejected","analyzedSha":"9ad36f7a2cce60488e6ec52283efb32efddaf93a","analyzedAt":"2026-08-20T13:07:44.778Z","schemaVersion":2},"datasetVersion":"2026-08-31T09:17:48.483Z"}