Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

datastore(fix): Fixes previous PR which was inadvertently creating multiple websockets. #2719

Merged
merged 1 commit into from
Feb 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading