Skip to content

Commit bc0a576

Browse files
committed
Revert "fix: allow Parse.Cloud.beforeSubscribe rejections to be caught by query.subscribe"
This reverts commit 3073b77.
1 parent 3073b77 commit bc0a576

File tree

4 files changed

+2
-48
lines changed

4 files changed

+2
-48
lines changed

integration/test/ParseLiveQueryTest.js

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -256,31 +256,4 @@ describe('Parse LiveQuery', () => {
256256
object.set({ foo: 'bar' });
257257
await object.save();
258258
});
259-
260-
it('live query can handle beforeConnect and beforeSubscribe errors', async () => {
261-
const client = new Parse.LiveQueryClient({
262-
applicationId: 'integration',
263-
serverURL: 'ws://localhost:1337',
264-
javascriptKey: null,
265-
masterKey: null,
266-
sessionToken: null,
267-
installationId: null,
268-
});
269-
client.open();
270-
const query = new Parse.Query('TestError');
271-
let subscription = client.subscribe(query);
272-
await expectAsync(subscription.subscribePromise).toBeRejectedWith(
273-
new Parse.Error(141, 'not allowed to subscribe')
274-
);
275-
client.close();
276-
await reconfigureServer({
277-
cloud: `${__dirname}/cloud/before_connect.js`,
278-
});
279-
client.open();
280-
subscription = client.subscribe(query);
281-
await expectAsync(subscription.subscribePromise).toBeRejectedWith(
282-
new Parse.Error(141, 'not allowed to connect')
283-
);
284-
client.close();
285-
});
286259
});

integration/test/cloud/before_connect.js

Lines changed: 0 additions & 3 deletions
This file was deleted.

integration/test/cloud/main.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,3 @@ Parse.Cloud.job('CloudJob2', function () {
4848
Parse.Cloud.job('CloudJobFailing', function () {
4949
throw 'cloud job failed';
5050
});
51-
52-
Parse.Cloud.beforeSubscribe('TestError', () => {
53-
throw 'not allowed to subscribe';
54-
});

src/LiveQueryClient.js

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import EventEmitter from './EventEmitter';
1414
import ParseObject from './ParseObject';
1515
import LiveQuerySubscription from './LiveQuerySubscription';
1616
import { resolvingPromise } from './promiseUtils';
17-
import ParseError from './ParseError';
1817

1918
// The LiveQuery client inner state
2019
const CLIENT_STATE = {
@@ -219,10 +218,6 @@ class LiveQueryClient extends EventEmitter {
219218
this.subscriptions.set(this.requestId, subscription);
220219
this.requestId += 1;
221220
this.connectPromise.then(() => {
222-
if (this.connectError) {
223-
subscription.subscribePromise.reject(this.connectError);
224-
return;
225-
}
226221
this.socket.send(JSON.stringify(subscribeRequest));
227222
});
228223

@@ -387,16 +382,10 @@ class LiveQueryClient extends EventEmitter {
387382
setTimeout(() => subscription.emit(SUBSCRIPTION_EMMITER_TYPES.OPEN, response), 200);
388383
}
389384
break;
390-
case OP_EVENTS.ERROR: {
391-
const parseError = new ParseError(data.code, data.error);
392-
if (!this.id) {
393-
this.connectError = parseError;
394-
this.connectPromise.resolve();
395-
this.state = CLIENT_STATE.DISCONNECTED;
396-
}
385+
case OP_EVENTS.ERROR:
397386
if (data.requestId) {
398387
if (subscription) {
399-
subscription.subscribePromise.reject(parseError);
388+
subscription.subscribePromise.resolve();
400389
setTimeout(() => subscription.emit(SUBSCRIPTION_EMMITER_TYPES.ERROR, data.error), 200);
401390
}
402391
} else {
@@ -409,7 +398,6 @@ class LiveQueryClient extends EventEmitter {
409398
this._handleReconnect();
410399
}
411400
break;
412-
}
413401
case OP_EVENTS.UNSUBSCRIBED:
414402
// We have already deleted subscription in unsubscribe(), do nothing here
415403
break;

0 commit comments

Comments
 (0)