{"record":{"id":"0271bf0127283046","repo":"grafana/k6","slug":"newresolver-v-w","errorCode":null,"errorMessage":"newResolver(%+v): %w","messagePattern":"newResolver\\(%\\+v\\): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/common/network_manager.go","lineNumber":111,"sourceCode":"\n\twg sync.WaitGroup\n}\n\n// NewNetworkManager creates a new network manager.\nfunc NewNetworkManager(\n\tctx context.Context,\n\tcustomMetrics *k6ext.CustomMetrics,\n\ts session,\n\tfm *FrameManager,\n\tparent *NetworkManager,\n\tei eventInterceptor,\n) (*NetworkManager, error) {\n\tvu := k6ext.GetVU(ctx)\n\tstate := vu.State()\n\n\tresolver, err := newResolver(state.Options.DNS)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"newResolver(%+v): %w\", state.Options.DNS, err)\n\t}\n\n\tm := NetworkManager{\n\t\tBaseEventEmitter: NewBaseEventEmitter(ctx),\n\t\tctx:              ctx,\n\t\t// TODO: Pass an internal logger instead of basing it on k6's logger?\n\t\t// See https://go.k6.io/k6/v2/js/modules/k6/browser/issues/54\n\t\tlogger:                        log.New(state.Logger, GetIterationID(ctx)),\n\t\tsession:                       s,\n\t\tparent:                        parent,\n\t\tframeManager:                  fm,\n\t\tresolver:                      resolver,\n\t\tvu:                            vu,\n\t\tcustomMetrics:                 customMetrics,\n\t\treqIDToRequest:                make(map[network.RequestID]*Request),\n\t\treqIDToRequestWillBeSentEvent: make(map[network.RequestID]*network.EventRequestWillBeSent),\n\t\treqIDToRequestPausedEvent:     make(map[network.RequestID]*fetch.EventRequestPaused),\n\t\textraInfoTracker:              newExtraInfoTracker(),","sourceCodeStart":93,"sourceCodeEnd":129,"githubUrl":"https://github.com/grafana/k6/blob/93accf6570dcd306ca5e99cc44c393ee3797761b/internal/js/modules/k6/browser/common/network_manager.go#L93-L129","documentation":"Thrown while creating a browser NetworkManager (i.e., when a new browser context/page initializes networking) if the DNS resolver cannot be built from the test's dns options. The only real failure path is an invalid dns.ttl string, which surfaces as newResolver(...): parsing TTL: invalid DNS TTL: <value> in the wrapped chain.","triggerScenarios":"Creating a page/context while k6 options contain dns.ttl that parseTTL cannot parse: anything other than '0', 'inf', empty, or a single valid duration (e.g. 'abc', '-1m', or a comma list like '60s,5m' that k6's HTTP stack accepts but the browser module does not split).","commonSituations":"Reusing an existing k6 HTTP options block with a comma-separated TTL list in a browser test; typo'd duration units ('1hr' instead of '1h'); negative TTL values; environment-specific options files injected via --config.","solutions":["Set dns.ttl to a single valid value: '0', 'inf', or one duration like '1m'","Remove or override the dns block for browser scenarios if HTTP-only options leak in via --config or exported options","Validate the duration syntax: number plus unit s/m/h (no 'hr', no negatives, no lists)","When both HTTP and browser tests share options, keep ttl single-valued so both stacks accept it"],"exampleFix":"// before (k6 options, valid for HTTP module but breaks browser module)\nexport const options = { dns: { ttl: '60s,5m', select: 'first' } };\n\n// after\nexport const options = { dns: { ttl: '60s', select: 'first' } };","handlingStrategy":"validation","validationCode":"// fail fast at init instead of at page creation\nconst TTL = __ENV.K6_DNS_TTL || '1m';\nif (!/^(0|inf|\\d+(\\.\\d+)?(ms|s|m|h))$/.test(TTL)) {\n  throw new Error(`invalid dns.ttl: ${TTL}`);\n}\nexport const options = { dns: { ttl: TTL } };","typeGuard":"function isValidTtl(v) {\n  return v === '0' || v === 'inf' || v === '' || /^\\d+(\\.\\d+)?(ms|s|m|h)$/.test(v);\n}","tryCatchPattern":null,"preventionTips":["Keep dns.ttl single-valued; never reuse HTTP-style TTL lists in browser tests","Lint exported options in CI for dns-ttl syntax","Remember the full chain: this fires at first page creation, not at parse time"],"tags":["browser","dns","config","options","ttl"],"backgroundTag":null,"analyzedSha":"93accf6570dcd306ca5e99cc44c393ee3797761b","analyzedAt":"2026-08-15T21:23:27.118Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}