{"record":{"id":"2df46395cec7f907","repo":"microsoft/FASTER","slug":"pending-reads-not-supported-with-pub-sub-2df463","errorCode":null,"errorMessage":"Pending reads not supported with pub/sub","messagePattern":"Pending reads not supported with pub/sub","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"cs/remote/src/FASTER.server/WebsocketServerSession.cs","lineNumber":600,"sourceCode":"            if (!status.IsPending)\n            {\n                // Write six bytes (message | status | sid)\n                hrw.Write(message, ref dcurr, (int)(dend - dcurr));\n                Write(ref status, ref dcurr, (int)(dend - dcurr));\n                Write(sid, ref dcurr, (int)(dend - dcurr));\n                if (prefix)\n                    serializer.Write(ref key, ref dcurr, (int)(dend - dcurr));\n                if (valPtr != null)\n                {\n                    ref Value value = ref serializer.ReadValueByRef(ref valPtr);\n                    serializer.Write(ref value, ref dcurr, (int)(dend - dcurr));\n                }\n                else if (status.Found)\n                    serializer.SkipOutput(ref dcurr);\n            }\n            else\n            {\n                throw new Exception(\"Pending reads not supported with pub/sub\");\n            }\n\n            // Send replies\n            var dtemp = d + 10;\n            var dstart = dtemp + sizeof(int);\n            Unsafe.AsRef<BatchHeader>(dstart).NumMessages = 1;\n            Unsafe.AsRef<BatchHeader>(dstart).SeqNo = 0;\n            int packetLen = (int)((dcurr - 10) - d);\n\n            CreateSendPacketHeader(ref d, packetLen);\n\n            *(int*)dtemp = (packetLen - sizeof(int));\n            networkSender.SendResponse((int) (d - networkSender.GetResponseObjectHead()), (int)(dcurr - d));\n        }\n\n\n        [MethodImpl(MethodImplOptions.AggressiveInlining)]\n        private static unsafe bool WriteOpSeqId(ref int o, ref byte* dst, int length)","sourceCodeStart":582,"sourceCodeEnd":618,"githubUrl":"https://github.com/microsoft/FASTER/blob/321d872eabda6a0345c8bd76419f89723ed864ae/cs/remote/src/FASTER.server/WebsocketServerSession.cs#L582-L618","documentation":"WebsocketServerSession (the pub/sub websocket backend) throws the same error as the binary pub/sub path: reads that complete with Pending status cannot be handled by the pub/sub reply logic. The websocket Publish path serializes exactly one reply batch and has no machinery to track/resume pending read completions, so a pending read is an unsupported operation.","triggerScenarios":"A websocket client sends a ReadRequest (or read with ReadOptions that defers completion) to a session backed by the pub/sub provider, and the read returns status Pending in WebsocketServerSession's Publish processing loop.","commonSituations":"Using the websocket FASTER server with the pub/sub subsystem while a client library issues normal reads; porting a client from a store-backed session to a pub/sub session without changing read usage.","solutions":["Restrict websocket pub/sub sessions to Publish/Subscribe traffic; issue reads against store-backed sessions only.","Switch the client to a regular (non-pub/sub) wire-format session if reads are required.","Adjust read issuance (drop ReadOptions that make reads pend) or use subscribe-based data delivery instead."],"exampleFix":"// before\nwsClient.Read(key); // pub/sub websocket session -> pending read\n// after\nwsClient.Subscribe(keyPrefix); // receive data via subscription","handlingStrategy":"validation","validationCode":"// before opening the websocket session, ensure reads go to a store-backed session\nbool isPubSubSession = sessionProvider is PubSubSessionProvider;\nif (isPubSubSession && issuesReads) throw new InvalidOperationException(\"Configure reads on a non-pub/sub session\");","typeGuard":null,"tryCatchPattern":"try { wsClient.Read(key); } catch (Exception) { /* route reads to a store-backed session */ }","preventionTips":["Design websocket pub/sub clients to use Subscribe/Publish exclusively.","Document that Read + ReadOptions (pending reads) requires a store-backed session."],"tags":["csharp","faster","websocket","pubsub","unsupported-operation"],"backgroundTag":"unsupported-operation","analyzedSha":"321d872eabda6a0345c8bd76419f89723ed864ae","analyzedAt":"2026-09-15T22:18:00.693Z","contentChangedAt":"2026-09-15T22:18:00.693Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}