Skip to content

Commit

Permalink
fix(pubsub): surface graphql connection failure error to observers (#…
Browse files Browse the repository at this point in the history
…10421)

<!--
Please make sure to read the Pull Request Guidelines:

https://github.com/aws-amplify/amplify-js/blob/main/CONTRIBUTING.md#pull-requests
-->

#### Description of changes
<!--
Thank you for your Pull Request! Please provide a description above and
review
the requirements below.
-->
Follow up to #10235.
In previous change, AppSyncRealTimeProvider blocks the GraphQL
connection error to the subscribers. This breaks in the integration test
[when subscription is
disabled](https://app.circleci.com/pipelines/github/aws-amplify/amplify-js/14982/workflows/93104c1c-ba16-432a-8d71-19831b335d37/jobs/155531).
This fixes the unintended breaking change.

#### Issue #, if available
<!-- Also, please reference any associated PRs for documentation
updates. -->



#### Description of how you validated changes
Validated the change in the Cypress integ test locally.



#### Checklist
<!-- Remove items that do not apply. For completed items, change [ ] to
[x]. -->

- [x] PR description included
- [x] `yarn test` passes
- [ ] Tests are [changed or
added](https://github.com/aws-amplify/amplify-js/blob/main/CONTRIBUTING.md#steps-towards-contributions)
- [ ] Relevant documentation is changed or added (and PR referenced)

By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache 2.0 license.
  • Loading branch information
stocaaro committed Oct 4, 2022
2 parents 1cbaede + 04f5160 commit 5341c9f
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions packages/pubsub/src/Providers/AWSAppSyncRealTimeProvider/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -593,6 +593,16 @@ export class AWSAppSyncRealTimeProvider extends AbstractPubSubProvider {
`${CONTROL_MSG.CONNECTION_FAILED}: ${JSON.stringify(payload)}`
);

observer.error({
errors: [
{
...new GraphQLError(
`${CONTROL_MSG.CONNECTION_FAILED}: ${JSON.stringify(payload)}`
),
},
],
});

if (startAckTimeoutId) clearTimeout(startAckTimeoutId);

if (typeof subscriptionFailedCallback === 'function') {
Expand Down

0 comments on commit 5341c9f

Please sign in to comment.