Skip to content

Commit 3f51599

Browse files
committed
Merge pull request #73 from cfnelson/master
Added try/catch for uncaught JSON parse error.
2 parents 38e97b8 + 01298a3 commit 3f51599

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

lib/ddp-client.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -362,8 +362,13 @@ DDPClient.prototype._makeSockJSConnection = function() {
362362
if (err) {
363363
self._recoverNetworkError();
364364
} else if (body) {
365-
var info = JSON.parse(body);
366-
if(!info.base_url) {
365+
var info;
366+
try {
367+
info = JSON.parse(body);
368+
} catch (e) {
369+
console.error(e);
370+
}
371+
if (!info || !info.base_url) {
367372
// no base_url, then use pure WS handling
368373
var url = self._buildWsUrl();
369374
self._makeWebSocketConnection(url);

0 commit comments

Comments
 (0)