{"record":{"id":"5a63ce31fbdbd29a","repo":"grafana/k6","slug":"failed-to-create-a-new-stream-w","errorCode":null,"errorMessage":"failed to create a new stream: %w","messagePattern":"failed to create a new stream: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/grpc/stream.go","lineNumber":101,"sourceCode":"\t\tMethod:                 s.method,\n\t\tMethodDescriptor:       s.methodDescriptor,\n\t\tDiscardResponseMessage: p.DiscardResponseMessage,\n\t\tTagsAndMeta:            &p.TagsAndMeta,\n\t\tMetadata:               p.Metadata,\n\t}\n\n\tctx := s.vu.Context()\n\tvar cancel context.CancelFunc\n\n\tif p.Timeout != time.Duration(0) {\n\t\tctx, cancel = context.WithTimeout(ctx, p.Timeout)\n\t}\n\n\ts.timeoutCancel = cancel\n\n\tstream, err := s.client.conn.NewStream(ctx, *req)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to create a new stream: %w\", err)\n\t}\n\ts.stream = stream\n\tmetrics.PushIfNotDone(s.vu.Context(), s.vu.State().Samples, metrics.Sample{\n\t\tTimeSeries: metrics.TimeSeries{\n\t\t\tMetric: s.instanceMetrics.Streams,\n\t\t\tTags:   s.tagsAndMeta.Tags,\n\t\t},\n\t\tTime:     time.Now(),\n\t\tMetadata: s.tagsAndMeta.Metadata,\n\t\tValue:    1,\n\t})\n\n\tgo s.loop()\n\n\treturn nil\n}\n\nfunc (s *stream) loop() {","sourceCodeStart":83,"sourceCodeEnd":119,"githubUrl":"https://github.com/grafana/k6/blob/3fcf5388d78cb382f0c0d42ec556a06bfd1b8dee/internal/js/modules/k6/grpc/stream.go#L83-L119","documentation":"Raised by the internal gRPC stream setup in beginStream when grpc-go's conn.NewStream fails to open a new stream over the underlying HTTP/2 connection. This wraps the underlying gRPC error and typically fires before any message is sent — e.g. when the connection is closed, the server refuses the stream, the named method is unknown, or a configured per-stream timeout (p.Timeout) expired before the stream headers could be sent.","triggerScenarios":"Thrown at internal/js/modules/k6/grpc/stream.go:101 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check the wrapped error for a gRPC status code to identify the cause (Unavailable, DeadlineExceeded, Unimplemented)","Verify the connection is still open and the client was not closed before calling send() on the stream","Increase the timeout value passed in the stream params if the deadline is being exceeded","Retry stream creation with backoff for transient Unavailable errors"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"3fcf5388d78cb382f0c0d42ec556a06bfd1b8dee","analyzedAt":"2026-08-18T03:05:52.393Z","contentChangedAt":"2026-08-18T03:05:52.393Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}