-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Clarify platform reading API (#2925)
At the moment, the `read_buffer` function of the `Platform` trait (representing how the light client binds to the environment) returns either `Some` in normal situations or `None` if the connection has been either closed or reset. This PR turns this `Option` into an enum with three variants: `Open`, `Closed`, and `Reset`. This lets the code properly differentiate between these two latter situations. Additionally, I've renamed "closed" to "reset" in the entire Wasm<->JS code (all the functions and variables), for clarity. While the `Platform` trait lets you report that the reading side is closed but the writing side still open, the JS code can't represent that state. Instead, it's either "connection open" or "connection reset". This PR fixes #2782. The issue was that we were treating `read_buffer()` returning `None` as meaning "reading side closed", but actually the entire connection was already reset. We would then call `send` on the already-reset connection, leading to the error. This kind of confusion is exactly why I've performed the rename. Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
- Loading branch information
1 parent
a413d18
commit 3c407df
Showing
12 changed files
with
183 additions
and
129 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.