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

Only emit error event for fatal errors #92

Merged
merged 1 commit into from
Apr 27, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 26 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ stream.

#### error event

The `error` event will be emitted whenever an error occurs, usually while
The `error` event will be emitted once a fatal error occurs, usually while
trying to read from this stream.
The event receives a single `Exception` argument for the error instance.

Expand All @@ -134,23 +134,23 @@ $server->on('error', function (Exception $e) {
});
```

This event MAY be emitted any number of times, which should be zero
times if this is a stream that is successfully terminated.
It SHOULD be emitted whenever the stream detects an error, such as a
transmission error or after an unexpected `data` or premature `end` event.
It SHOULD NOT be emitted after a `close` event.
This event SHOULD be emitted once the stream detects a fatal error, such
as a fatal transmission error or after an unexpected `data` or premature
`end` event.
It SHOULD NOT be emitted after a previous `error`, `end` or `close` event.
It MUST NOT be emitted if this is not a fatal error condition, such as
a temporary network issue that did not cause any data to be lost.

After the stream errors, it MUST close the stream and SHOULD thus be
followed by a `close` event and then switch to non-readable mode, see
also `close()` and `isReadable()`.

Many common streams (such as a TCP/IP connection or a file-based stream)
only deal with data transmission and do not make assumption about data
boundaries (such as unexpected `data` or premature `end` events).
In other words, many lower-level protocols (such as TCP/IP) may choose
to only emit this for a fatal transmission error once and will thus
likely close (terminate) the stream in response.
If this is a fatal error that results in the stream being closed, it
SHOULD be followed by a `close` event.

Other higher-level protocols may choose to keep the stream alive after
this event, if they can recover from an error condition.
to only emit this for a fatal transmission error once and will then
close (terminate) the stream in response.

If this stream is a `DuplexStreamInterface`, you should also notice
how the writable side of the stream also implements an `error` event.
Expand All @@ -177,7 +177,7 @@ see also `isReadable()`.
Unlike the `end` event, this event SHOULD be emitted whenever the stream
closes, irrespective of whether this happens implicitly due to an
unrecoverable error or explicitly when either side closes the stream.
If you only want to detect a *succesful* end, you should use the `end`
If you only want to detect a *successful* end, you should use the `end`
event instead.

Many common streams (such as a TCP/IP connection or a file-based stream)
Expand Down Expand Up @@ -434,7 +434,7 @@ This event is mostly used internally, see also `pipe()` for more details.

#### error event

The `error` event will be emitted whenever an error occurs, usually while
The `error` event will be emitted once a fatal error occurs, usually while
trying to write to this stream.
The event receives a single `Exception` argument for the error instance.

Expand All @@ -444,21 +444,20 @@ $stream->on('error', function (Exception $e) {
});
```

This event MAY be emitted any number of times, which should be zero
times if this is a stream that is successfully terminated.
It SHOULD be emitted whenever the stream detects an error, such as a
transmission error.
It SHOULD NOT be emitted after a `close` event.
This event SHOULD be emitted once the stream detects a fatal error, such
as a fatal transmission error.
It SHOULD NOT be emitted after a previous `error` or `close` event.
It MUST NOT be emitted if this is not a fatal error condition, such as
a temporary network issue that did not cause any data to be lost.

After the stream errors, it MUST close the stream and SHOULD thus be
followed by a `close` event and then switch to non-writable mode, see
also `close()` and `isWritable()`.

Many common streams (such as a TCP/IP connection or a file-based stream)
only deal with data transmission and may choose
to only emit this for a fatal transmission error once and will thus
likely close (terminate) the stream in response.
If this is a fatal error that results in the stream being closed, it
SHOULD be followed by a `close` event.

Other higher-level protocols may choose to keep the stream alive after
this event, if they can recover from an error condition.
to only emit this for a fatal transmission error once and will then
close (terminate) the stream in response.

If this stream is a `DuplexStreamInterface`, you should also notice
how the readable side of the stream also implements an `error` event.
Expand Down
28 changes: 14 additions & 14 deletions src/ReadableStreamInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
* stream.
*
* error event:
* The `error` event will be emitted whenever an error occurs, usually while
* The `error` event will be emitted once a fatal error occurs, usually while
* trying to read from this stream.
* The event receives a single `Exception` argument for the error instance.
*
Expand All @@ -89,23 +89,23 @@
* });
* ```
*
* This event MAY be emitted any number of times, which should be zero
* times if this is a stream that is successfully terminated.
* It SHOULD be emitted whenever the stream detects an error, such as a
* transmission error or after an unexpected `data` or premature `end` event.
* It SHOULD NOT be emitted after a `close` event.
* This event SHOULD be emitted once the stream detects a fatal error, such
* as a fatal transmission error or after an unexpected `data` or premature
* `end` event.
* It SHOULD NOT be emitted after a previous `error`, `end` or `close` event.
* It MUST NOT be emitted if this is not a fatal error condition, such as
* a temporary network issue that did not cause any data to be lost.
*
* After the stream errors, it MUST close the stream and SHOULD thus be
* followed by a `close` event and then switch to non-readable mode, see
* also `close()` and `isReadable()`.
*
* Many common streams (such as a TCP/IP connection or a file-based stream)
* only deal with data transmission and do not make assumption about data
* boundaries (such as unexpected `data` or premature `end` events).
* In other words, many lower-level protocols (such as TCP/IP) may choose
* to only emit this for a fatal transmission error once and will thus
* likely close (terminate) the stream in response.
* If this is a fatal error that results in the stream being closed, it
* SHOULD be followed by a `close` event.
*
* Other higher-level protocols may choose to keep the stream alive after
* this event, if they can recover from an error condition.
* to only emit this for a fatal transmission error once and will then
* close (terminate) the stream in response.
*
* If this stream is a `DuplexStreamInterface`, you should also notice
* how the writable side of the stream also implements an `error` event.
Expand All @@ -131,7 +131,7 @@
* Unlike the `end` event, this event SHOULD be emitted whenever the stream
* closes, irrespective of whether this happens implicitly due to an
* unrecoverable error or explicitly when either side closes the stream.
* If you only want to detect a *succesful* end, you should use the `end`
* If you only want to detect a *successful* end, you should use the `end`
* event instead.
*
* Many common streams (such as a TCP/IP connection or a file-based stream)
Expand Down
25 changes: 12 additions & 13 deletions src/WritableStreamInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
* This event is mostly used internally, see also `pipe()` for more details.
*
* error event:
* The `error` event will be emitted whenever an error occurs, usually while
* The `error` event will be emitted once a fatal error occurs, usually while
* trying to write to this stream.
* The event receives a single `Exception` argument for the error instance.
*
Expand All @@ -69,21 +69,20 @@
* });
* ```
*
* This event MAY be emitted any number of times, which should be zero
* times if this is a stream that is successfully terminated.
* It SHOULD be emitted whenever the stream detects an error, such as a
* transmission error.
* It SHOULD NOT be emitted after a `close` event.
* This event SHOULD be emitted once the stream detects a fatal error, such
* as a fatal transmission error.
* It SHOULD NOT be emitted after a previous `error` or `close` event.
* It MUST NOT be emitted if this is not a fatal error condition, such as
* a temporary network issue that did not cause any data to be lost.
*
* After the stream errors, it MUST close the stream and SHOULD thus be
* followed by a `close` event and then switch to non-writable mode, see
* also `close()` and `isWritable()`.
*
* Many common streams (such as a TCP/IP connection or a file-based stream)
* only deal with data transmission and may choose
* to only emit this for a fatal transmission error once and will thus
* likely close (terminate) the stream in response.
* If this is a fatal error that results in the stream being closed, it
* SHOULD be followed by a `close` event.
*
* Other higher-level protocols may choose to keep the stream alive after
* this event, if they can recover from an error condition.
* to only emit this for a fatal transmission error once and will then
* close (terminate) the stream in response.
*
* If this stream is a `DuplexStreamInterface`, you should also notice
* how the readable side of the stream also implements an `error` event.
Expand Down