{"record":{"id":"a50118aa6cc9072f","repo":"m1k1o/neko","slug":"errcapturepipelinealreadyexists","errorCode":"ErrCapturePipelineAlreadyExists","errorMessage":"capture pipeline already exists","messagePattern":"capture pipeline already exists","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"server/pkg/types/capture.go","lineNumber":17,"sourceCode":"package types\n\nimport (\n\t\"context\"\n\t\"errors\"\n\t\"fmt\"\n\t\"math\"\n\t\"strings\"\n\t\"time\"\n\n\t\"github.com/m1k1o/neko/server/pkg/types/codec\"\n\n\t\"github.com/PaesslerAG/gval\"\n)\n\nvar (\n\tErrCapturePipelineAlreadyExists = errors.New(\"capture pipeline already exists\")\n)\n\ntype Sample struct {\n\t// timing information\n\tTimestamp time.Time\n\tDuration  time.Duration\n\t// metadata\n\tDeltaUnit bool // this unit cannot be decoded independently.\n\t// buffer length\n\tLength int\n\t// buffer with encoded media\n\tData []byte\n}\n\ntype SampleListener interface {\n\tWriteSample(Sample)\n}\n","sourceCodeStart":1,"sourceCodeEnd":35,"githubUrl":"https://github.com/m1k1o/neko/blob/b0f01cedea68893e85a3fd852c0521238c285695/server/pkg/types/capture.go#L1-L35","documentation":"ErrCapturePipelineAlreadyExists is a sentinel error returned when creating a capture pipeline (screen/audio streaming pipeline) whose ID already has an active pipeline in the capture manager. It guards against duplicate stream creation for the same source (e.g. the same screen or audio device).","triggerScenarios":"Calling CreatePipeline/start for a stream ID that already has a running pipeline; calling recreatePipelines when the pipeline already exists; concurrent creation of the same stream ID from two requests.","commonSituations":"Double-start of screencast/audio streaming (e.g. API retried); two browser clients requesting the same capture source without reuse; dev code calling start() manually when the stream is already running.","solutions":["Check for this sentinel error with errors.Is and treat it as success (pipeline already running)","Stop the existing pipeline before creating a new one with the same ID","Reuse the existing pipeline/stream instead of creating a new one","Serialize/streamline creation calls so the same ID is not created concurrently"],"exampleFix":"// before\nerr := captureMgr.CreatePipeline(streamID, ...)\nif err != nil { return err }\n// after\nerr := captureMgr.CreatePipeline(streamID, ...)\nif errors.Is(err, types.ErrCapturePipelineAlreadyExists) {\n  return nil // already running, reuse\n}\nif err != nil { return err }","handlingStrategy":"try-catch","validationCode":"// check before creating\nif _, err := captureMgr.Image(streamID); err == nil {\n  // pipeline already running; reuse it\n}","typeGuard":"func pipelineExists(mgr types.CaptureManager, id string) bool {\n  _, err := mgr.Image(id)\n  return err == nil\n}","tryCatchPattern":"err := mgr.CreatePipeline(id, ...)\nif errors.Is(err, types.ErrCapturePipelineAlreadyExists) {\n  // treat as success, reuse existing pipeline\n}","preventionTips":["Track which streams you already started","Use errors.Is against the sentinel error instead of string matching","Reuse existing pipelines instead of stop/recreate cycles","Serialize creation of the same stream ID"],"tags":["capture","pipeline","streaming"],"backgroundTag":"resource-already-exists","analyzedSha":"b0f01cedea68893e85a3fd852c0521238c285695","analyzedAt":"2026-09-01T10:35:56.638Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}