Attach error codes to all receiver errors by pimterry · Pull Request #1901 · websockets/ws (original) (raw)
However in this case it is not unsupported. The error in this case is that the message length exceeds the maximum allowed message length as defined by the maxPayload option.
That's what I mean by 'unsupported'. Messages that go beyond it aren't "invalid" - imo invalid means against the specification, i.e. this will never work on any conformant websocket connection.
With 'unsupported' I'm trying to say that it may be valid, and it might work elsewhere, but it won't work on this connection right now (e.g. due to the configured maxPayload option). That matches standard use elsewhere - e.g. close code 1003 ("unsupported data" - valid data in a format that this server can't process) or HTTP 415 ("unsupported media type" - a valid request with a media type that this server refuses to handle).
I think that fits both this case (unsupported due to ws maxPayload config) and the other case (unsupported due to JS limitations).
I see what you mean about data frame size vs total message size though. How about we split the two cases into:
WS_ERR_UNSUPPORTED_MESSAGE_LENGTH- overall message is too long (> maxPayload)WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH- a single data frame is too long (> 2^53-1)