Skip to content
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

Handling parity errors with a ReadableStream #51

Open
reillyeon opened this issue Sep 28, 2018 · 4 comments
Open

Handling parity errors with a ReadableStream #51

reillyeon opened this issue Sep 28, 2018 · 4 comments

Comments

@reillyeon
Copy link
Collaborator

When parity error detection is enabled it is unclear how this should be communicated to a client using the ReadableStream interface. Unlike the errors that can be encountered in the response body of a fetch() these are not fatal. The options as I see it,

  1. Ignore errors.
  2. Halt the ReadableStream when an error is detected and require the error to be explicitly cleared to open a new stream that will receive the next byte after the error.
  3. Signal errors in-band using a mechanism similar to the PARMRK flag on POSIX systems. The application will need to inspect the input byte by byte to separate errors from the actual data.
@reillyeon
Copy link
Collaborator Author

@reconbot how is this handled in node-serialport?

@reconbot
Copy link
Contributor

reconbot commented Sep 29, 2018 via email

@reconbot
Copy link
Contributor

If I were to add it to serialport, I'd handle it underneath our node streams layer at the binding layer and which would probably expose it as a configuration settings, for choosing the error character and if possible having it produce a read error. I need to do more research to know what's possible.

Our bindings needs better docs but it looks something like this and I'm working on a next version with lessons learned on this spec serialport/node-serialport#1679 I'm still exploring the api. Since the binding layer is closer to the actual syscalls and doesn't have a concept of a stream, we can use it to build node streams, ReadableStream, async iterator, or whatever interface is de jour.

@domenic
Copy link
Collaborator

domenic commented Aug 7, 2020

It looks like the current explainer has settled on (2). This is an interesting point on the design space, and I think it's pretty reasonable. (3) seems most "natural" in some ways but also quite inconvenient for web developers. /cc @ricea as the other Streams editor since this might set an interesting precedent.

I'll also offer

  1. Signal errors out of band, e.g. with an ever-growing port.readingErrors property, which the application can optionally consult after each read.

I'm not sure on the details there and it might be bad. E.g., I guess you return zero-byte Uint8Arrays when there's an error? Hmm. Anyway, I think it's worse than (2).

But the real purpose of my comment is to encourage you to add an "Alternatives considered" section to the explainer exploring these different alternatives and their tradeoffs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants