parse-community / Parse-SDK-JS
Showing 1 of 2 files from the diff.

@@ -14,6 +14,7 @@
Loading
14 14
import ParseObject from './ParseObject';
15 15
import LiveQuerySubscription from './LiveQuerySubscription';
16 16
import { resolvingPromise } from './promiseUtils';
17 +
import ParseError from './ParseError';
17 18
18 19
// The LiveQuery client inner state
19 20
const CLIENT_STATE = {
@@ -217,9 +218,13 @@
Loading
217 218
    const subscription = new LiveQuerySubscription(this.requestId, query, sessionToken);
218 219
    this.subscriptions.set(this.requestId, subscription);
219 220
    this.requestId += 1;
220 -
    this.connectPromise.then(() => {
221 -
      this.socket.send(JSON.stringify(subscribeRequest));
222 -
    });
221 +
    this.connectPromise
222 +
      .then(() => {
223 +
        this.socket.send(JSON.stringify(subscribeRequest));
224 +
      })
225 +
      .catch(error => {
226 +
        subscription.subscribePromise.reject(error);
227 +
      });
223 228
224 229
    return subscription;
225 230
  }
@@ -382,10 +387,15 @@
Loading
382 387
        setTimeout(() => subscription.emit(SUBSCRIPTION_EMMITER_TYPES.OPEN, response), 200);
383 388
      }
384 389
      break;
385 -
    case OP_EVENTS.ERROR:
390 +
    case OP_EVENTS.ERROR: {
391 +
      const parseError = new ParseError(data.code, data.error);
392 +
      if (!this.id) {
393 +
        this.connectPromise.reject(parseError);
394 +
        this.state = CLIENT_STATE.DISCONNECTED;
395 +
      }
386 396
      if (data.requestId) {
387 397
        if (subscription) {
388 -
          subscription.subscribePromise.resolve();
398 +
          subscription.subscribePromise.reject(parseError);
389 399
          setTimeout(() => subscription.emit(SUBSCRIPTION_EMMITER_TYPES.ERROR, data.error), 200);
390 400
        }
391 401
      } else {
@@ -398,6 +408,7 @@
Loading
398 408
        this._handleReconnect();
399 409
      }
400 410
      break;
411 +
    }
401 412
    case OP_EVENTS.UNSUBSCRIBED:
402 413
      // We have already deleted subscription in unsubscribe(), do nothing here
403 414
      break;
Files Coverage
src 99.90%
Project Totals (61 files) 99.90%

No yaml found.

Create your codecov.yml to customize your Codecov experience

Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading