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

Uncaught "Call is cancelled" subscription exception #202

Closed
BenTilbrook opened this issue Jul 17, 2019 · 7 comments
Closed

Uncaught "Call is cancelled" subscription exception #202

BenTilbrook opened this issue Jul 17, 2019 · 7 comments
Assignees
Labels
bug Something isn't working

Comments

@BenTilbrook
Copy link

BenTilbrook commented Jul 17, 2019

Describe the bug
An uncaught exception in the subscription code is crashing Android apps. There is evidently no way to prevent this from occurring.

To Reproduce
Not commonly reproducable. Might be a multithreading problem. However, the code in question is obviously a poor way to handle the problem.

Expected behavior
The exception is caught and logged or ignored.

Environment

  • AppSync SDK Version: 2.10.0

Device Information

  • Device: Pixel 2 API 28 Emulator 29.0.12-5613046
  • Android version: 9.0 (Pie) - API 28

Stacktrace

java.lang.RuntimeException: Cancelled
        at com.apollographql.apollo.internal.RealAppSyncSubscriptionCall$1.run(RealAppSyncSubscriptionCall.java:80)
        at java.lang.Thread.run(Thread.java:764)
     Caused by: com.apollographql.apollo.exception.ApolloCanceledException: Call is cancelled.
        at com.apollographql.apollo.internal.RealAppSyncSubscriptionCall$1.run(RealAppSyncSubscriptionCall.java:80) 
        at java.lang.Thread.run(Thread.java:764) 
@palpatim palpatim added AppSync bug Something isn't working labels Jul 17, 2019
@palpatim
Copy link
Contributor

@btilbrook-nextfaze

Thanks for the report. If you have any context around cases where you have seen this crash (e.g., what user activity was in process at the time, or led up to the crash), that would be helpful.

@BenTilbrook
Copy link
Author

One thing I can say is it seems to be happening when a delta sync subscription is cancelled very shortly after starting.

@BenTilbrook
Copy link
Author

BenTilbrook commented Sep 5, 2019

The code in question uses a synchronized (this) block in an attempt to declare a critical section, but appears to be a programming error, because this refers to the enclosing anonymous Runnable instance, which is created anew every time.

@TrekSoft
Copy link
Contributor

TrekSoft commented Oct 2, 2019

Sorry for the delay - we'll discuss this on our Friday bug bash

@TrekSoft TrekSoft self-assigned this Oct 4, 2019
@TrekSoft
Copy link
Contributor

TrekSoft commented Oct 7, 2019

Hey, looked into this and you were 100% right about the two issues you raised in that throwing the exception inside the separate thread would always cause the crash and the "this" reference was wrong - I've fixed both of these in the code to rather than throw an exception inside the thread, pass the error back through the callback and we'll now be writing a test to ensure it works before releasing it. Will update this when it's released.

@BenTilbrook
Copy link
Author

Great news. Thanks for looking into this - much appreciated!

@TrekSoft
Copy link
Contributor

TrekSoft commented Oct 17, 2019

@btilbrook-nextfaze the release 2.10.1 contains the fix - feel free to reopen this issue if you see any more problems with this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants