Commit ba7f368b81bcbddeae02d80184c379d5c849a24b
document order that callbacks must be called during an abort
Dominic Tarr committed on 4/24/2016, 8:22:13 AMParent: a4e2fe6fffcdd836e472a276536499fee878188e
Files changed
spec.md | changed |
spec.md | ||
---|---|---|
@@ -25,8 +25,10 @@ | ||
25 | 25 | Sometimes it's the sink that errors, and if it can't read anymore then we _must_ abort the source. (example, source is a file stream from local fs, and sink is a http upload. prehaps the network drops or remote server crashes, in this case we should abort the source, so that it's resources can be released.) |
26 | 26 | |
27 | 27 | To abort the sink, call read with a truthy first argument. You may abort a source _before_ it has returned from a regular read. (if you wait for the previous read to complete, it's possible you'd get a deadlock, if you a reading a stream that takes a long time, example, `tail -f` is reading a file, but nothing has appended to that file yet). |
28 | 28 | |
29 | +When a stream is aborted during a read, the callback provided to the read function *must* be called first, with an error, and then the abort callback. | |
30 | + | |
29 | 31 | ## Sink Streams |
30 | 32 | |
31 | 33 | A Sink Stream (aka writable stream) is a function that a Source Stream is passed to. The Sink Stream calls the `read` function of the Source Stream, abiding by the rules about when it may not call. |
32 | 34 |
Built with git-ssb-web