{"record":{"id":"38925d0828c60747","repo":"denoland/deno","slug":"cannot-specify-start-end-and-duration-toge","errorCode":null,"errorMessage":"Cannot specify \"start\", \"end\", and \"duration\" together in options","messagePattern":"Cannot specify \"start\", \"end\", and \"duration\" together in options","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"ext/web/15_performance.js","lineNumber":761,"sourceCode":"      );\n\n    if (endMark !== undefined) {\n      endMark = webidl.converters.DOMString(endMark, prefix, \"Argument 3\");\n    }\n\n    if (\n      startOrMeasureOptions && typeof startOrMeasureOptions === \"object\" &&\n      ObjectKeys(startOrMeasureOptions).length > 0\n    ) {\n      if (endMark) {\n        throw new TypeError('Options cannot be passed with \"endMark\"');\n      }\n      if (\n        ReflectHas(startOrMeasureOptions, \"start\") &&\n        ReflectHas(startOrMeasureOptions, \"duration\") &&\n        ReflectHas(startOrMeasureOptions, \"end\")\n      ) {\n        throw new TypeError(\n          'Cannot specify \"start\", \"end\", and \"duration\" together in options',\n        );\n      }\n    }\n    let endTime;\n    if (endMark) {\n      endTime = convertMarkToTimestamp(endMark);\n    } else if (\n      typeof startOrMeasureOptions === \"object\" &&\n      ReflectHas(startOrMeasureOptions, \"end\")\n    ) {\n      endTime = convertMarkToTimestamp(startOrMeasureOptions.end);\n    } else if (\n      typeof startOrMeasureOptions === \"object\" &&\n      ReflectHas(startOrMeasureOptions, \"start\") &&\n      ReflectHas(startOrMeasureOptions, \"duration\")\n    ) {\n      const start = convertMarkToTimestamp(startOrMeasureOptions.start);","sourceCodeStart":743,"sourceCodeEnd":779,"githubUrl":"https://github.com/denoland/deno/blob/9ad36f7a2cce60488e6ec52283efb32efddaf93a/ext/web/15_performance.js#L743-L779","documentation":"In performance.measure()'s options object, the timestamps \"start\", \"end\", and \"duration\" over-determine the measurement — any two imply the third. The spec therefore forbids supplying all three at once, and Deno throws this TypeError from ext/web/15_performance.js when Reflect.has finds all three keys present (even if a value is undefined). Remove one key and let the API derive it.","triggerScenarios":"performance.measure(\"m\", { start: 0, end: 100, duration: 100 }); options built by merging a defaults object containing all keys with caller overrides; a duration computed as end-start and then also passing start and end.","commonSituations":"Spreading `{ start: 0, end: 0, duration: 0 }` defaults into every measure call; autogenerated options from a benchmarking framework that fills all fields; keys present with undefined values still trigger the check because it uses key presence, not value.","solutions":["Delete one of the three keys — typically duration, since it equals end minus start.","Audit spreads of default option objects and remove keys that callers also set.","If the value for a key is unknown, omit the key entirely rather than setting it to undefined.","Validate measure options with your own check: at most two of start/end/duration present."],"exampleFix":"// before\nperformance.measure(\"m\", { start: 0, end: 100, duration: 100 });\n\n// after\nperformance.measure(\"m\", { start: 0, end: 100 });","handlingStrategy":"validation","validationCode":"function normalizeMeasure(o) {\n  const keys = [\"start\", \"end\", \"duration\"];\n  if (keys.every((k) => k in o)) delete o.duration; // derivable\n  return o;\n}\nperformance.measure(\"m\", normalizeMeasure(opts));","typeGuard":"function hasAllThreeTimestamps(o) {\n  return \"start\" in o && \"end\" in o && \"duration\" in o;\n}","tryCatchPattern":"try { performance.measure(n, opts); } catch (e) { if (e instanceof TypeError && e.message.includes('\"duration\"')) { delete opts.duration; performance.measure(n, opts); } else throw e; }","preventionTips":["Never spread { start, end, duration } defaults into measure options.","Omit unknown keys entirely instead of setting undefined — presence alone triggers the throw.","Compute duration after the call via entry durations rather than passing it in."],"tags":["performance","performance-mark","web-api","typeerror"],"backgroundTag":"conflicting-options-parameters","analyzedSha":"9ad36f7a2cce60488e6ec52283efb32efddaf93a","analyzedAt":"2026-08-20T13:07:44.778Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}