Skip to content

Commit

Permalink
Protects against multiple connects
Browse files Browse the repository at this point in the history
  • Loading branch information
philstrong authored and Phil Strong committed Apr 8, 2016
1 parent b9dc08a commit f0f3e48
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/eventsource.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,11 @@ function EventSource(url, eventSourceInitDict) {
if (res.statusCode == 204) return self.close();
return
}

// protect against multiple connects
if (readyState === EventSource.OPEN) {
return;
}

readyState = EventSource.OPEN;
res.on('close', onConnectionClosed);
res.on('end', onConnectionClosed);
Expand Down

0 comments on commit f0f3e48

Please sign in to comment.