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

Recoverable error from failed parameter validation? #1280

Open
saschanaz opened this issue May 25, 2023 · 4 comments
Open

Recoverable error from failed parameter validation? #1280

saschanaz opened this issue May 25, 2023 · 4 comments

Comments

@saschanaz
Copy link
Member

There have been some questions from WebTransport and File System where their algorithms have validation steps:

Both of them want to tell the caller that the parameter is invalid, but it cannot be recovered without getting a new stream as the validation error stops the existing stream. There's no good try-catch for those streams.

Maybe File System can do the validation early in its FileSystemWritableFileStream.write() without errorring the stream, but do we want other specs to get their own methods for this? Perhaps also related to #1072.

cc @jesup @jan-ivar @jjjalkanen

@ricea
Copy link
Collaborator

ricea commented May 26, 2023

The lack of "soft" errors in WritableStream was an intentional design decision to avoid situations where one of a number of queued writes fails and leaves the output corrupted due to the missing chunk.

In File System, writing a chunk with a missing field is clearly an authoring error and I think making it recoverable would just encourage authors to not fix their bugs.

The case of an "incorrect buffer size" with WebTransport datagrams is a weird one caused by us ascribing semantics to buffer boundaries in byte streams which was not intended by the streams specification. It can easily be averted by always using buffers of size 65536, so I'm not too worried about our unfriendly behaviour of erroring the whole stream.

I think the absence of a hard/soft error distinction makes the standard more predictable and easy-to-use, even if in some cases richer error signalling would be attractive.

@saschanaz
Copy link
Member Author

saschanaz commented May 26, 2023

where one of a number of queued writes fails and leaves the output corrupted due to the missing chunk.

This is an interesting point. Can we do the validation early before queuing? (i.e. have a separate "validation step"?)

@MattiasBuelens
Copy link
Collaborator

MattiasBuelens commented May 26, 2023

Can we do the validation early before queuing? (i.e. have a separate "validation step"?)

The problem is that the WritableStream may be part of a long pipe chain. If the writable throws a "soft" error, then there's nowhere for that error to go.

@saschanaz
Copy link
Member Author

saschanaz commented May 26, 2023

Can we do the validation early before queuing? (i.e. have a separate "validation step"?)

The problem is that the WritableStream may be part of a long pipe chain. If the writable throws a "soft" error, then there's nowhere for that error to go.

Exactly, and that's why I mentioned FileSystemWritableFileStream.write(), which theoretically can be made to run additional steps separate from the write algorithm and thus do not affect piping (i.e. let it fail hard as it does now).

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

No branches or pull requests

3 participants