Skip to content

fix: await AppSyncEvent WebSocket connection establishment #14438

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

Merged
merged 3 commits into from
Jun 25, 2025

Conversation

Simone319
Copy link
Contributor

@Simone319 Simone319 commented Jun 19, 2025

Description of changes

This PR fix the race condition between web socket connection and subsequent publish event while using AppSyncEvents.

Before this change, the web socket connection Promise is resolve while the connection is still being established. It allows subsequent publish event calls to the web socket connection is ready.

Now the web socket connection Promise will be resolved only when the connection is established completely.

Issue #, if available

Description of how you validated changes

Run unit, E2E tests and verified manually that WebSocket connection is established before any event is being published.

Checklist

  • PR description included
  • yarn test passes
  • Unit Tests are changed or added
  • Relevant documentation is changed or added (and PR referenced)

Checklist for repo maintainers

  • Verify E2E tests for existing workflows are working as expected or add E2E tests for newly added workflows
  • New source file paths included in this PR have been added to CODEOWNERS, if appropriate

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Siteproxy
@Simone319 Simone319 requested a review from a team as a code owner June 19, 2025 16:13
soberm
soberm previously approved these changes Jun 19, 2025
test('socket status should be READY', async () => {

// Connect to the provider
const connectPromise = provider.connect({
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we assert that the socket status is 'connecting' after this statement?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, will add the check as well.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
@Simone319 Simone319 merged commit 88113b6 into main Jun 25, 2025
30 checks passed
@Simone319 Simone319 deleted the fix/appsync_connect branch June 25, 2025 14:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants