{"record":{"id":"c658a91f3fc40033","repo":"grafana/k6","slug":"metric-flush-period-should-be-positive-but-was-s","errorCode":null,"errorMessage":"metric flush period should be positive but was %s","messagePattern":"metric flush period should be positive but was (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"output/helpers.go","lineNumber":91,"sourceCode":"\t\t\treturn\n\t\t}\n\t}\n}\n\n// Stop waits for the periodic flusher flush one last time and exit. You can\n// safely call Stop() multiple times from different goroutines, you just can't\n// call it from inside of the flushing function.\nfunc (pf *PeriodicFlusher) Stop() {\n\tpf.once.Do(func() {\n\t\tclose(pf.stop)\n\t})\n\t<-pf.stopped\n}\n\n// NewPeriodicFlusher creates a new PeriodicFlusher and starts its goroutine.\nfunc NewPeriodicFlusher(period time.Duration, flushCallback func()) (*PeriodicFlusher, error) {\n\tif period <= 0 {\n\t\treturn nil, fmt.Errorf(\"metric flush period should be positive but was %s\", period)\n\t}\n\n\tpf := &PeriodicFlusher{\n\t\tperiod:        period,\n\t\tflushCallback: flushCallback,\n\t\tstop:          make(chan struct{}),\n\t\tstopped:       make(chan struct{}),\n\t\tonce:          &sync.Once{},\n\t}\n\n\tgo pf.run()\n\n\treturn pf, nil\n}\n","sourceCodeStart":73,"sourceCodeEnd":106,"githubUrl":"https://github.com/grafana/k6/blob/01ffac6f245854c1b8adc6a69857c76a15f90022/output/helpers.go#L73-L106","documentation":"NewPeriodicFlusher rejected the requested flush period because it was zero or negative. The periodic flusher needs a strictly positive interval to schedule its flush goroutine; callers typically derive it from a flush-period configuration option, so the real fault is an invalid configured period.","triggerScenarios":"Thrown at output/helpers.go:91 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Set the relevant flush period option to a positive duration (e.g. K6_METRIC_FLUSH_INTERVAL='1s' or output-specific flush period settings)","Check the units — a bare number may parse as nanoseconds or fail validation","Ensure no configuration layer sets the period to 0 or a negative value"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"01ffac6f245854c1b8adc6a69857c76a15f90022","analyzedAt":"2026-08-18T03:05:52.393Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}