Permalink
Browse files

TOOLS-1590 Write after end errors should be handled in Watershed

Reviewed by: Josh Wilsdon <jwilsdon@joyent.com>
Reviewed by: Joshua M. Clulow <jmc@joyent.com>
Approved by: Joshua M. Clulow <jmc@joyent.com>
1 parent 5109e83 commit 84d01ea350c5bd7ade083badf08c49fef46e125b @richardkiene richardkiene committed with jclulow Oct 28, 2016
Showing with 15 additions and 2 deletions.
  1. +5 −0 CHANGES.md
  2. +9 −1 lib/watershed.js
  3. +1 −1 package.json
View
@@ -2,6 +2,11 @@
## not yet released
+## 0.3.3
+
+* Handle write-after-end errors when an attempt is made to write to a
+ websocket that cannot be written to.
+
## 0.3.2
* Initial move to Joyent org plus make check
View
@@ -326,7 +326,15 @@ WatershedConnection(options, socket)
return;
self._end_emitted = true;
- if (err.code === 'ECONNRESET' || err.code === 'EPIPE') {
+ /*
+ * Unfortunately, in the case of a write-after-end error there
+ * is no error code set. In this case we check that the error
+ * message property is equal to the string 'write after end' as
+ * it is specified in the node runtime.
+ */
+ if (err.code === 'ECONNRESET' ||
+ err.code === 'EPIPE' ||
+ err.message === 'write after end') {
/*
* Treat end-of-stream errors as merely an end
* of stream. If we received a CLOSE frame, it
View
@@ -1,6 +1,6 @@
{
"name": "watershed",
- "version": "0.3.2",
+ "version": "0.3.3",
"description": "simple websockets (RFC6455) client and server",
"main": "./lib/watershed.js",
"author": "Joshua M. Clulow <jmc@joyent.com>",

0 comments on commit 84d01ea

Please sign in to comment.