-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RPC message parser can support arbitrary whitespace such as '\n' within and between JSON RPC messages #1
Comments
Arbitrary newlines and spaces should be possible. |
Any whitespace that could exist... can be automatically discarded and should not hit the buffer limit. |
Might need to just check what jsonstream parser supports. It could be limited to only a single character delimiter or no delimiters, if it can take in variable length delimitation of arbitrary whitespace, that would also be useful. |
Regarding websocket transport, each websocket frame is already a separate message frame. Therefore, when we are translating websocket connections to web streams, we are simply concatenating the messages in the stream. Due to being transport agnostic, the stream has no idea that the underlying transport, in this case websocket is already doing message framing. It just appears as a continuous byte stream to the RPC handler. This issue is therefore about enabling the ability to parse optional unlimited whitespace in between complete JSON RPC messages. In fact... it should be possible to parse unlimited whitespace anywhere that the JSON spec allows. This would depend on the jsonstream parser and what it is capable of doing. Note that after the HTTP handshake, every websocket frame is already binary on the wire-level. It's not a text protocol like HTTP 1.1. This means even if The addition of However for quic as the transport, there's no equivalent to the websocket frame. Anyway... the problem is 2 things:
It is important that if whitespace were to exist inside the JSON stream, that these whitespace characters are dropped to avoid a build up of memory. If they are in fact dropped, they should not count towards our buffer limit. This needs to be verified. |
Going to move this to |
Hey @addievo don't close issues directly. Only when a PR is merged is the issue auto-closed. |
Since the PR hasn't been merged. You need to say |
The core goal of this issue is to allow the stream JSON parser to allow for arbitrary white-space for it's input. What the We want to allow for arbitrary white space in the stream when separating the messages. So any combination of white space should be valid on the stream. For example the following should be valid
Note that this is on the input to the parser and stream transform. This is to allow flexibility with 3rd parties using the RPC API. I for example could connect to the rpc through netcat and write my own hand crafted JSONRPC messages that are separated by newlines. |
|
callers and handlers are now refactored * WIP - Newline now works, refers issue #1 node v20 fix feat: handlers implementations are now abstract arrow functions * Fixes #5 [ci skip] * resolves issue 5, makes RPC handlers abstract arrow function properties feat: rename to uppercase [ci skip] fix: handler export fix [ci skip] fix: tsconf from quic [ci skip] fix: dependencies (js quic), events and errors versions, changing to relative imports, jest dev dependency, js-quic tsconfig [ci skip] fix: tests imports, using @ [ci skip] chore: removed sysexits chore: fix default exports for callers and handlers Fixed index for handlers fix: remove @matrixai/id fix: remove @matrixai/id and ix chore : diagram [ci skip] chore : lintfix fix: errors now extend AbstractError [ci skip] fix: undoing fix #1 [ci skip] replacd errorCode with just code, references std error codes from rpc spec feat: events based createDestroy [ci skip] chore: img format fix [ci skip] chore: img in README.md [ci skip] feat: allows the user to pass in a generator function if the user wishes to specify a particular id [ci skip] fix: fixes #7 * Removes graceTimer and related jests chore: idGen name change. idGen parameter in creation and constructor. No longer optional. Only defaulted in one place. wip: added idgen to jests, was missing. [ci skip] wip: reimported ix, since a few tests rely on it. removed, matrixai/id wip: jests for #4 removed, matrixai/id wip: * Implements custom RPC Error codes. * Fixed jest for concurrent timeouts * All errors now have a cause * All errors now use custom error codes. wip: *Client uses ctx timer now wip: *Jests to test concurrency wip: *custom RPC based errors for RPC Client, now all errors have a cause and an error message WIP: * Refactor out sensitiveReplacer WIP: * Refactor out sensitiveReplacer WIP: * Update to latest async init and events * set default timeout to Infinity * jest to check server and client with infinite timeout * fixing jests which broke after changing default timeout to infinity WIP: f1x #4 WIP: f1x #11 f1x: parameterize toError, fromError and replacer wip: tofrom fix: parameterize toError, fromError and replacer fix: Makes concurrent jests non deterministic * Related #4 fix: parameterize replacer toError and fromError, change fromError to return JSONValue, stringify fromError usages * Related #10 fix: Converted global state for fromError to handle it internally. *Related: #10 Reviewed-by: @tegefaulkes [ci skip] chore: Jests for fromError and toError, and using a custom replacer. related: #10 [ci skip]
Will depend on juanjoDiaz/streamparser-json#35. Putting this into the to do to revisit. |
@addievo what does that have to do with this problem? |
In case you don't follow the streamparser-json repo, it turns our that using random whitespaces as separators was always allowed by simply setting the |
@amydevs can you verify if this is is already done as per the comment by @juanjoDiaz? |
Upstream says it is supported already. @tegefaulkes @aryanjassal can check if this can be a quick fix. |
Specification
Currently the agnostic RPC message parser separates the messages based on the
}{
boundry., which makes it difficult to read messages since they are in a single line.The objective is to improve readability by formatting a message with newlines and whitespaces, and ensuring that the parser is able to handle these characters.
This should be possible by adjusting the
separator
parameter which should be able to discard the newline and other whitespace characters when constructing the JsonStreamParser. (Constructing the stream)Additional context
Related MatrixAI/Polykey#249
Related MatrixAI/Polykey#498
Tasks
The text was updated successfully, but these errors were encountered: