documentation icon indicating copy to clipboard operation
documentation copied to clipboard

Add note about streaming server error responses

Open mjankowski opened this issue 2 months ago • 3 comments

Resolves https://github.com/mastodon/documentation/issues/1505

This is just attempting to solve the "we literally only mention event responses and don't contemplate errors" aspect of that page. Possible future improvement here would be to more exhaustively list error conditions?

mjankowski avatar Nov 08 '25 21:11 mjankowski

I’m not sure this is correct, what I was seeing before (assuming this is still the case) was not an HTTP 4XX response, but just the JSON body sent over the websocket protocol.

daprice avatar Nov 08 '25 21:11 daprice

IIRC how I encountered this before, more specifically, was:

  1. Open a “blank” websocket connection to wss://[domain]/api/v1/streaming, specifying the access token in the Sec-WebSocket-Protocol header (this is also undocumented I think!) but not specifying any parameters for what to subscribe to (the ability to open a “blank” socket without specifying an initial stream is yet a third undocumented thing, I think!)
  2. Send a valid “subscribe” payload over the socket
  3. (at this point, the server starts sending Event objects like the documentation says)
  4. Send another “subscribe” payload over the websocket with a mistake, such as a misspelled "stream" parameter
  5. (At this point, the server sends a message over the websocket containing the JSON error payload, but this is not an actual websocket protocol or HTTP error, just an unexpected message sent over the socket. AFAICT, the websocket stays open and the server will still continue sending Events from the previous successful subscription in addition to the error JSON)

daprice avatar Nov 08 '25 22:11 daprice

Good overview -- tried to add some nuance around those separate types of errors (which both share that error key including JSON)

mjankowski avatar Nov 09 '25 14:11 mjankowski