Skip to content

Commit

Permalink
datastore(fix): Fixes previous PR which was inadvertently creating mu…
Browse files Browse the repository at this point in the history
…ltiple websockets. (#2719)
  • Loading branch information
tylerjroach authored Feb 19, 2024
1 parent 1804551 commit 14acc3b
Showing 1 changed file with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -141,17 +141,17 @@ <T> void requestSubscription(
pendingSubscriptionIds.add(subscriptionId);
socketListener = webSocketListener;
socket = webSocket;
}

// Every request waits here for the connection to be ready.
Connection connection = socketListener.waitForConnectionReady();
if (connection.hasFailure()) {
// If the latch didn't count all the way down
if (pendingSubscriptionIds.remove(subscriptionId)) {
// The subscription was pending, so we need to emit an error.
onSubscriptionError.accept(
new ApiException(connection.getFailureReason(), AmplifyException.TODO_RECOVERY_SUGGESTION));
return;
// Every request waits here for the connection to be ready.
Connection connection = socketListener.waitForConnectionReady();
if (connection.hasFailure()) {
// If the latch didn't count all the way down
if (pendingSubscriptionIds.remove(subscriptionId)) {
// The subscription was pending, so we need to emit an error.
onSubscriptionError.accept(
new ApiException(connection.getFailureReason(), AmplifyException.TODO_RECOVERY_SUGGESTION));
return;
}
}
}

Expand Down Expand Up @@ -257,7 +257,7 @@ private void notifySubscriptionData(String subscriptionId, String data) throws A
dispatcher.dispatchNextMessage(data);
}

synchronized void releaseSubscription(String subscriptionId) throws ApiException {
void releaseSubscription(String subscriptionId) throws ApiException {
// First thing we should do is remove it from the pending subscription collection so
// the other methods can't grab a hold of the subscription.
final Subscription<?> subscription = subscriptions.get(subscriptionId);
Expand Down

0 comments on commit 14acc3b

Please sign in to comment.