-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
API.cancel doesn't work #9198
Comments
Hi @gweisz-440it - perhaps you haven't included it in your sample, but have you tried |
Hey @david-mcafee in the example isCancel receives an error, I have no error, since the api.graphql promise resolves correctly after some time (even though it was cancelled), please see the log times |
Hello, I'm facing the same issue. Even if I cancel the request immediately, nothing happens and no errors are thrown. |
also have the same problem |
I tried debugging the issue by adding a console log to the amplify code:
and source returns as |
I've done a little more digging, and it seems that the |
It seems like the |
@jowo-io You are on the right track looking at the amplify-js/packages/api/src/API.ts Lines 157 to 164 in d9dfff3
I believe changing line 162 to return this._restApi.cancel(request, message) || this._graphqlApi.cancel(request, message); should fix this issue |
@jamesaucode ahh, i see! that's brilliant though thanks for opening the PR on this issue. |
This issue has been automatically locked since there hasn't been any recent activity after it was closed. Please open a new issue for related bugs. Looking for a help forum? We recommend joining the Amplify Community Discord server |
Before opening, please confirm:
JavaScript Framework
React Native
Amplify APIs
GraphQL API
Amplify Categories
api
Environment information
Describe the bug
We are trying to standardize an app behavior under poor connection scenarios, what we'd like to achieve is to cancel pending GraphQL requests if these don't fulfill under a given timeframe.
For that purpose we've already implemented the time related logic, but when we try to cancel the pending requests with the API.cancel as described in https://docs.amplify.aws/lib/graphqlapi/cancel-request/q/platform/js/ it does nothing
We have also tried to get help in the discord channels but without any response, other ppl seem to have incurred into the same issue
We've taken care of using the original promise (not a wrapped one) to cancel the request as the documentation warns
Expected behavior
We expect that when calling API.cancel the request is immediately cancelled
Reproduction steps
To easily explain what we are expecting to happen, a 'simple example' is provided as a code snippet, in this example, and based on what we see in the documentation, we expect an error to be thrown, but instead the request is completed normally
Code Snippet
Log output
aws-exports.js
No response
Manual configuration
No response
Additional configuration
No response
Mobile Device
No response
Mobile Operating System
No response
Mobile Browser
No response
Mobile Browser Version
No response
Additional information and screenshots
No response
The text was updated successfully, but these errors were encountered: