grafana/k6 · error

parsing TTL

Error message

parsing TTL: %w

What it means

Failure to parse a TTL string into time.Duration while building the resolver from the DNS options. The sentinel is produced by parseTTL (which accepts 'inf', '0', or an extended duration) — the offending input is the ttl value of the k6 DNS configuration.

Solutions

  1. Set dns.ttl to 'inf', '0', or a valid duration like '300s' / '5m'
  2. Avoid arbitrary strings; ttl must be an extended Go duration
  3. Check environment-variable-provided DNS settings for typos
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at internal/js/modules/k6/browser/common/network_manager.go:169 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of grafana/k6@8d06114777 (2026-08-18). Data as JSON: /api/errors/56ecfb38ea415d36. Report an issue: GitHub.

Appendix: source

Thrown at internal/js/modules/k6/browser/common/network_manager.go:169

		"connectionaborted":    network.ErrorReasonConnectionAborted,
		"connectionclosed":     network.ErrorReasonConnectionClosed,
		"connectionfailed":     network.ErrorReasonConnectionFailed,
		"connectionrefused":    network.ErrorReasonConnectionRefused,
		"connectionreset":      network.ErrorReasonConnectionReset,
		"internetdisconnected": network.ErrorReasonInternetDisconnected,
		"namenotresolved":      network.ErrorReasonNameNotResolved,
		"timedout":             network.ErrorReasonTimedOut,
		"failed":               network.ErrorReasonFailed,
	}
}

// Returns a new Resolver.
// Copied with minor changes from
// https://github.com/grafana/k6/blob/fb70bc6f3d3f22a40e65f32deea3cea1b6d70a76/js/runner.go#L459
func newResolver(conf k6types.DNSConfig) (k6netext.Resolver, error) {
	ttl, err := parseTTL(conf.TTL.String)
	if err != nil {
		return nil, fmt.Errorf("parsing TTL: %w", err)
	}

	dnsSel := conf.Select
	if !dnsSel.Valid {
		dnsSel = k6types.DefaultDNSConfig().Select
	}
	dnsPol := conf.Policy
	if !dnsPol.Valid {
		dnsPol = k6types.DefaultDNSConfig().Policy
	}
	return k6netext.NewResolver(
		net.LookupIP, ttl, dnsSel.DNSSelect, dnsPol.DNSPolicy), nil
}

// Parse a string representation of TTL to time.Duration.
// Copied from https://github.com/grafana/k6/blob/fb70bc6f3d3f22a40e65f32deea3cea1b6d70a76/js/runner.go#L479
func parseTTL(ttlS string) (time.Duration, error) {
	ttl := time.Duration(0)

View on GitHub (pinned to 8d06114777)