{"record":{"id":"85c59961a9015282","repo":"grafana/k6","slug":"invalid-dns-ttl-s","errorCode":null,"errorMessage":"invalid DNS TTL: %s","messagePattern":"invalid DNS TTL: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/common/network_manager.go","lineNumber":201,"sourceCode":"\n// Parse a string representation of TTL to time.Duration.\n// Copied from https://github.com/grafana/k6/blob/fb70bc6f3d3f22a40e65f32deea3cea1b6d70a76/js/runner.go#L479\nfunc parseTTL(ttlS string) (time.Duration, error) {\n\tttl := time.Duration(0)\n\tswitch ttlS {\n\tcase \"inf\":\n\t\t// cache \"infinitely\"\n\t\tttl = time.Hour * 24 * 365\n\tcase \"0\":\n\t\t// disable cache\n\tcase \"\":\n\t\tttlS = k6types.DefaultDNSConfig().TTL.String\n\t\tfallthrough\n\tdefault:\n\t\tvar err error\n\t\tttl, err = k6types.ParseExtendedDuration(ttlS)\n\t\tif ttl < 0 || err != nil {\n\t\t\treturn ttl, fmt.Errorf(\"invalid DNS TTL: %s\", ttlS)\n\t\t}\n\t}\n\treturn ttl, nil\n}\n\nfunc (m *NetworkManager) deleteRequestByID(reqID network.RequestID) {\n\tm.reqsMu.Lock()\n\tdefer m.reqsMu.Unlock()\n\tdelete(m.reqIDToRequest, reqID)\n}\n\nfunc (m *NetworkManager) emitRequestMetrics(req *Request) {\n\tstate := m.vu.State()\n\n\ttags := state.Tags.GetCurrentValues().Tags\n\tif state.Options.SystemTags.Has(k6metrics.TagMethod) {\n\t\ttags = tags.With(\"method\", req.method)\n\t}","sourceCodeStart":183,"sourceCodeEnd":219,"githubUrl":"https://github.com/grafana/k6/blob/93accf6570dcd306ca5e99cc44c393ee3797761b/internal/js/modules/k6/browser/common/network_manager.go#L183-L219","documentation":"Root error from parseTTL: the ttl string failed ParseExtendedDuration or parsed to a negative duration. Valid inputs are exactly '0' (cache disabled), 'inf' (cached ~1 year), '' (falls back to k6's default '1m'), or a single non-negative duration like '300s'/'5m'/'1h'. Comma-separated TTL lists are NOT supported in the browser module even though k6's HTTP stack accepts them.","triggerScenarios":"dns.ttl set to 'abc', '1hr', '-1m', or '60s,5m'. Empty string is fine (default applied); '0' and 'inf' are special-cased; everything else must parse as one non-negative duration.","commonSituations":"Sharing one options object between HTTP and browser scenarios where the HTTP side uses a TTL list; hand-edited durations with wrong units; negative values from templating bugs.","solutions":["Use a single valid duration: '1m', '300s', '1h', or '0'/'inf'","Never pass a comma list to dns.ttl in scripts that use the browser module","Sanity-check generated/templated options before running","If you need per-lookup TTL variety, keep it in HTTP-only scenarios and override dns.ttl for browser scenarios"],"exampleFix":"// before\nexport const options = { dns: { ttl: '60s,10m' } };\n\n// after\nexport const options = { dns: { ttl: '60s' } };","handlingStrategy":"validation","validationCode":"const ttl = '60s';\nif (!/^(0|inf|\\d+(\\.\\d+)?(ms|s|m|h))$/.test(ttl)) {\n  throw new Error(`dns.ttl '${ttl}' invalid; use 0, inf, or a single duration`);\n}","typeGuard":"function isValidTtlString(s) {\n  if (s === '' || s === '0' || s === 'inf') return true;\n  return /^\\d+(\\.\\d+)?(ms|s|m|h)$/.test(s); // no commas, no negatives\n}","tryCatchPattern":null,"preventionTips":["Memorize the valid set: '', '0', 'inf', single duration","Comma lists are HTTP-module-only; never in browser scenarios","Beware unit typos: '1hr' invalid, '1h' valid"],"tags":["browser","dns","ttl","config","validation"],"backgroundTag":null,"analyzedSha":"93accf6570dcd306ca5e99cc44c393ee3797761b","analyzedAt":"2026-08-15T21:23:27.118Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}