{"record":{"id":"ff3d2d217286a026","repo":"gofr-dev/gofr","slug":"jstream-error","errorCode":null,"errorMessage":"jStream error","messagePattern":"jStream error","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/gofr/datasource/pubsub/nats/errors.go","lineNumber":15,"sourceCode":"package nats\n\nimport \"errors\"\n\nvar (\n\t// Client Errors.\n\terrServerNotProvided       = errors.New(\"client server address not provided\")\n\terrSubjectsNotProvided     = errors.New(\"subjects not provided\")\n\terrConsumerNotProvided     = errors.New(\"consumer name not provided\")\n\terrConsumerCreationError   = errors.New(\"consumer creation error\")\n\terrFailedToDeleteStream    = errors.New(\"failed to delete stream\")\n\terrPublishError            = errors.New(\"publish error\")\n\terrJetStreamNotConfigured  = errors.New(\"jStream is not configured\")\n\terrJetStreamCreationFailed = errors.New(\"jStream creation failed\")\n\terrJetStream               = errors.New(\"jStream error\")\n\terrCreateStream            = errors.New(\"create stream error\")\n\terrDeleteStream            = errors.New(\"delete stream error\")\n\terrGetStream               = errors.New(\"get stream error\")\n\terrCreateOrUpdateStream    = errors.New(\"create or update stream error\")\n\terrHandlerError            = errors.New(\"handler error\")\n\terrConnectionError         = errors.New(\"connection error\")\n\terrSubscriptionError       = errors.New(\"subscription error\")\n)\n","sourceCodeStart":1,"sourceCodeEnd":24,"githubUrl":"https://github.com/gofr-dev/gofr/blob/187eb24962502e91f1fee856230670958b66e89c/pkg/gofr/datasource/pubsub/nats/errors.go#L1-L24","documentation":"errJetStream (errors.go:15) is the generic \"jStream error\" sentinel returned by jetStream()/validateJetStream when obtaining or validating the JetStream handle fails for reasons other than it simply being unconfigured. It wraps or accompanies underlying JetStream failures surfaced through Query/GetJetStreamStatus paths and health checks.","triggerScenarios":"Client.Query or health/status checks hitting a JetStream operation that errors (e.g. getting stream info) while the handle is present; validateJetStream failing after Connect; exercised by TestClient_Query_JetStreamError and TestClient_GetJetStreamStatus.","commonSituations":"JetStream temporarily unavailable mid-operation (server restarting, storage full); stream deleted while querying its status; connectivity dropped between connect and first JetStream call.","solutions":["Inspect the wrapped cause to identify the concrete JetStream failure (errors.Unwrap / %w chain).","Verify the referenced stream still exists (`nats stream info <name>`) — deleted streams surface as generic JS errors.","Check server health and disk/memory usage; JS returns errors when storage limits are hit.","Reconnect the client (retry Connect) if the connection dropped after JetStream was initialized."],"exampleFix":"// before: ignoring health-check errors\nstatus, _ := client.Query(ctx)\n// after: handle jetStream failure and reconnect\nif err != nil {\n    logger.Errorf(\"jetstream error: %v\", err)\n    _ = client.Connect()\n}","handlingStrategy":"try-catch","validationCode":"if js == nil {\n    return errors.New(\"jetstream handle missing\")\n}\nif err := js.Singleton(ctx) == nil; false {\n}","typeGuard":null,"tryCatchPattern":"status, err := client.Query(ctx)\nif err != nil {\n    if errors.Is(err, errJetStream) {\n        logger.Errorf(\"jetstream degraded: %v\", err)\n        // mark unhealthy and trigger reconnect\n    }\n    return err\n}","preventionTips":["Use the client health endpoint/Query in readiness probes.","Watch NATS disconnect/reconnect callbacks and reset JetStream state.","Monitor server storage/memory limits that trigger JS errors.","Log the wrapped cause, not just the sentinel."],"tags":["nats","jetstream","health-check","gofr"],"backgroundTag":"jetstream-operation-failed","analyzedSha":"187eb24962502e91f1fee856230670958b66e89c","analyzedAt":"2026-09-01T20:34:54.554Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}