{"record":{"id":"ead364db5dd66325","repo":"m1k1o/neko","slug":"webrtc-connection-not-found","errorCode":null,"errorMessage":"webrtc connection not found","messagePattern":"webrtc connection not found","errorType":"error_code","errorClass":"ErrWebRTCConnectionNotFound","httpStatus":null,"severity":"error","filePath":"server/pkg/types/webrtc.go","lineNumber":11,"sourceCode":"package types\n\nimport (\n\t\"errors\"\n\n\t\"github.com/pion/webrtc/v4\"\n)\n\nvar (\n\tErrWebRTCDataChannelNotFound = errors.New(\"webrtc data channel not found\")\n\tErrWebRTCConnectionNotFound  = errors.New(\"webrtc connection not found\")\n\tErrWebRTCStreamNotFound      = errors.New(\"webrtc stream not found\")\n)\n\ntype ICEServer struct {\n\tURLs       []string `mapstructure:\"urls\"       json:\"urls\"`\n\tUsername   string   `mapstructure:\"username\"   json:\"username,omitempty\"`\n\tCredential string   `mapstructure:\"credential\" json:\"credential,omitempty\"`\n}\n\ntype PeerVideo struct {\n\tDisabled bool   `json:\"disabled\"`\n\tID       string `json:\"id\"`\n\tVideo    string `json:\"video\"` // TODO: Remove this, used for compatibility with old clients.\n\tAuto     bool   `json:\"auto\"`\n}\n\ntype PeerVideoRequest struct {\n\tDisabled *bool           `json:\"disabled,omitempty\"`","sourceCodeStart":1,"sourceCodeEnd":29,"githubUrl":"https://github.com/m1k1o/neko/blob/b0f01cedea68893e85a3fd852c0521238c285695/server/pkg/types/webrtc.go#L1-L29","documentation":"ErrWebRTCConnectionNotFound is a sentinel error in the neko types package indicating that a WebRTC peer/connection lookup failed — no peer connection exists for the referenced session or identifier. It is returned when code tries to interact with (pause, video/audio config, signaling on) a peer that is not registered.","triggerScenarios":"Operations on a WebRTCPeer (SetPaused, SetVideo, CreateOffer, candidates) whose underlying *webrtc.PeerConnection is nil or already destroyed; referencing a peer by session after the session disconnected.","commonSituations":"Delayed signaling messages arriving after the peer was destroyed (tab close, network drop); server-side cleanup racing client requests; session re-created so old peer references are invalid.","solutions":["Re-create the peer via the WebRTC manager (CreatePeer) and redo signaling.","Ignore/drop stale signaling messages for destroyed peers instead of failing.","Check client logs for premature disconnects and network/ICE problems.","Ensure the session is connected before requesting media operations.","Upgrade/check versions — some flows changed around pion/webrtc v4 migration."],"exampleFix":"// before\npeer.SetPaused(false) // may return ErrWebRTCConnectionNotFound\n// after\nif peer == nil || peer.Connection() == nil {\n    return types.ErrWebRTCConnectionNotFound // caller recreates the peer\n}\npeer.SetPaused(false)","handlingStrategy":"validation","validationCode":"// ensure the session has a live peer before media operations\npeer := session.GetWebRTCPeer()\nif peer == nil {\n    return errors.New(\"no active webrtc peer for session\")\n}","typeGuard":"func HasPeer(s types.Session) bool { return s.GetWebRTCPeer() != nil }","tryCatchPattern":"if err := peer.SetPaused(false); err != nil {\n    if errors.Is(err, types.ErrWebRTCConnectionNotFound) {\n        // peer gone: trigger client reconnect/re-signaling\n        return\n    }\n    return err\n}","preventionTips":["Drop signaling messages for destroyed peers gracefully.","Recreate peers instead of reusing stale references after reconnect.","Monitor disconnect events to clean peer maps promptly.","Test against flaky networks to catch destroy races."],"tags":["webrtc","peer-connection","not-found","go"],"backgroundTag":"webrtc-peer-not-found","analyzedSha":"b0f01cedea68893e85a3fd852c0521238c285695","analyzedAt":"2026-09-01T10:35:56.638Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}