-
Notifications
You must be signed in to change notification settings - Fork 236
IPIP-332: Streaming Error Handling on Web Gateways #332
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
Closed
Closed
Changes from 2 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
8a175f6
ipip: error handling in gateways
hacdias a84fb63
ipip: cleanup streaming and should
hacdias 4e73544
Update IPIP/0000-gateway-error-handling.md
hacdias 8ccb87d
Merge branch 'main' into feat/error-handling-gateway
hacdias 9480caa
add stream close details for http 1.1 and http 2.0
hacdias a20a665
Update http-gateways/PATH_GATEWAY.md
hacdias e7f6b54
Update http-gateways/PATH_GATEWAY.md
hacdias 3e3b0fe
Merge branch 'main' into feat/error-handling-gateway
hacdias 0fcdd02
ipip: add headers info
hacdias 4dd1293
ipip: add header info
hacdias c0c6af7
ipip: update design
hacdias File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
# IPIP 0000: Streaming Error Handling in HTTP Gateways | ||
|
||
- Start Date: 2022-10-12 | ||
- Related Issues: | ||
- [ipfs/kubo/pull/9333](https://github.com/ipfs/kubo/pull/9333) | ||
- [mdn/browser-compat-data/issues/14703](https://github.com/mdn/browser-compat-data/issues/14703) | ||
|
||
## Summary | ||
|
||
Ensure streaming error handling in web gateways is clear and consistent. | ||
|
||
## Motivation | ||
|
||
Web gateways provide different functionalities where users can download files. | ||
The download of this files is streamed from the server to the client using HTTP. | ||
However, there is no good way of presenting to the client an error that happens | ||
during the stream. | ||
|
||
For example, if during the download of a TAR file, the server detects some error | ||
and is not able to continue, the user can get a valid, yet incomplete TAR. However, | ||
the user will not know that the TAR is incomplete. By introducing consistent error | ||
handling, the server attempts to notify the user. | ||
|
||
## Detailed design | ||
|
||
If the server encounters an error before streaming the contents to the client, | ||
the server must fail with the respective `4xx` or `5xx` HTTP status code (no change). | ||
|
||
If the server encounters an error while streaming the contents, the server must | ||
force-close the HTTP connection to the user. This way, the user will receive a | ||
network error, making it clear that the downloaded file is not valid. | ||
|
||
## Test fixtures | ||
|
||
There are no relevant test fixures for this IPIP. | ||
|
||
## Design rationale | ||
|
||
Before starting to stream the body of the response, the server is able to set | ||
an HTTP status code for the error. However, after the HTTP headers are set | ||
and the body started being streamed, there are no clear ways in the HTTP | ||
specification to show an error. Since the gateway is browser-first, it is | ||
important to show an error and avoid users receiving an incomplete file. | ||
Therefore, the server can force-close the HTTP connection, leading to a network | ||
error. This tells the user that an error happened. | ||
Jorropo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
### User benefit | ||
|
||
The user will know that an error happened while receiving the file. Otherwise, | ||
the user might receive incomplete, but still valid, files that could be mistaken | ||
but the real file. | ||
|
||
### Compatibility | ||
|
||
This RFC is backwards compatible. | ||
|
||
### Alternatives | ||
|
||
Using [`Trailer`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Trailer) HTTP headers | ||
was considered. However, trailer headers are [not supported in browsers](https://github.com/mdn/browser-compat-data/issues/14703). | ||
In addition, even if trailer headers were supported in browsers, there is no clear | ||
standard for which header would be used to indicate errors. | ||
|
||
### Copyright | ||
|
||
Copyright and related rights waived via [CC0](https://creativecommons.org/publicdomain/zero/1.0/). |
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.