{"record":{"id":"d804bbfe9b2790fd","repo":"nats-io/nats-server","slug":"memstore-is-nil","errorCode":null,"errorMessage":"memstore is nil","messagePattern":"memstore is nil","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/memstore.go","lineNumber":2594,"sourceCode":"\nfunc (ms *memStore) isClosed() bool {\n\tms.mu.RLock()\n\tdefer ms.mu.RUnlock()\n\treturn ms.msgs == nil\n}\n\ntype consumerMemStore struct {\n\tmu     sync.Mutex\n\tms     StreamStore\n\tname   string\n\tcfg    ConsumerConfig\n\tstate  ConsumerState\n\tclosed bool\n}\n\nfunc (ms *memStore) ConsumerStore(name string, _ time.Time, cfg *ConsumerConfig) (ConsumerStore, error) {\n\tif ms == nil {\n\t\treturn nil, fmt.Errorf(\"memstore is nil\")\n\t}\n\tif ms.isClosed() {\n\t\treturn nil, ErrStoreClosed\n\t}\n\tif cfg == nil || name == _EMPTY_ {\n\t\treturn nil, fmt.Errorf(\"bad consumer config\")\n\t}\n\to := &consumerMemStore{ms: ms, name: name, cfg: *cfg}\n\tms.AddConsumer(o)\n\treturn o, nil\n}\n\nfunc (ms *memStore) AddConsumer(o ConsumerStore) error {\n\tms.mu.Lock()\n\tms.consumers = append(ms.consumers, o)\n\tms.mu.Unlock()\n\treturn nil\n}","sourceCodeStart":2576,"sourceCodeEnd":2612,"githubUrl":"https://github.com/nats-io/nats-server/blob/3a66a489d262bf89b71a71c955c94920394532f3/server/memstore.go#L2576-L2612","documentation":"Nil-receiver guard in memStore.ConsumerStore: the method was invoked on a nil *memStore, meaning the stream store was never created or has been torn down before a consumer was attached to it.","triggerScenarios":"Thrown at server/memstore.go:2594 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check that the stream store was successfully created before adding consumers","Tear down consumers before closing/deleting the stream store"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"3a66a489d262bf89b71a71c955c94920394532f3","analyzedAt":"2026-09-02T04:41:54.247Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}