Skip to content

"Attempt to re-open an already-closed object: SQLiteDatabase" error on a Play Store pre-launch tests #498

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

Closed
3 tasks
keeprock opened this issue Nov 27, 2020 · 11 comments
Labels
bug Something isn't working platform: Android This is Android specific

Comments

@keeprock
Copy link

keeprock commented Nov 27, 2020

Current behavior

In a process of releasing a bundle to the Play Store, I received an errors on a pre-launch tests. It shows up as : «attempt to re-open an already-closed object: SQLiteDatabase /data/user/0/com.app/databases/RKStorage»

Expected behavior

App should not get any errors.

Repro steps

I've got two separate angles at which we can look at this problem.

  1. Automated Sentry error response:

My Sentry error system caught an exception, which may happen then an app has been closed after being put into a background (by pressing Home, I guess)

image

At first glance, the app is already to be closed, so why even bother? I don't know what the user actually saw, which makes me worry a bit. It doesn't happen before.

  1. Pre-launch tests from the Play Store

Also, there are pre-launch tests, which are mandatory before uploading an app to the Play Store. And they are showing the same errors.

image

Related issue - firebase/quickstart-unity#861.

Looks like a problem with pre-release test code on a Google side. But worth looking at any way, cause async-library being caught in an error log.

Thanks!

Environment

  • Platforms tested:
    • [8.1.0] Android Nokia 1
    • iOS
    • macOS
    • Windows
  • AsyncStorage version: 1.12.1
  • Environment:
    react-native: =0.63.3 => 0.63.3
  • Logs/Errors that may be relevant:
An error occurred while executing doInBackground()

android.os.AsyncTask$3 in done at line 353

    java.util.concurrent.FutureTask in finishCompletion at line 383
    java.util.concurrent.FutureTask in setException at line 252
    java.util.concurrent.FutureTask in run at line 271
    com.reactnativecommunity.asyncstorage.AsyncStorageModule$SerialExecutor$1 in run at line 63
    java.util.concurrent.ThreadPoolExecutor in runWorker at line 1162
    java.util.concurrent.ThreadPoolExecutor$Worker in run at line 636
    java.lang.Thread in run at line 764
IllegalStateException

attempt to re-open an already-closed object: SQLiteDatabase: /data/user/0/com.app/databases/RKStorage
    android.database.sqlite.SQLiteClosable in acquireReference at line 55
    android.database.sqlite.SQLiteDatabase in compileStatement at line 1068
    com.reactnativecommunity.asyncstorage.AsyncStorageModule$2 in doInBackgroundGuarded at line 228
    com.reactnativecommunity.asyncstorage.AsyncStorageModule$2 in doInBackgroundGuarded at line 219
    com.facebook.react.bridge.GuardedAsyncTask in doInBackground at line 36
    com.facebook.react.bridge.GuardedAsyncTask in doInBackground at line 20
    android.os.AsyncTask$2 in call at line 333
    java.util.concurrent.FutureTask in run at line 266
    com.reactnativecommunity.asyncstorage.AsyncStorageModule$SerialExecutor$1 in run at line 63
    java.util.concurrent.ThreadPoolExecutor in runWorker at line 1162
    java.util.concurrent.ThreadPoolExecutor$Worker in run at line 636
    java.lang.Thread in run at line 764
@tido64 tido64 added bug Something isn't working platform: Android This is Android specific labels Nov 28, 2020
@tido64
Copy link
Member

tido64 commented Dec 18, 2020

Do you have a repro or just logs? I think @krizzu worked in this area not too long ago. Any ideas?

@krizzu
Copy link
Member

krizzu commented Dec 18, 2020

Yup, this is something I addressed in the v1.12.1 release. The problem was that the db connection was not closed properly, causing more issue. In your example, it looks like there was some long-running task, which accessed AsyncStorage after the app was already closed?

@keeprock
Copy link
Author

keeprock commented Dec 21, 2020

@tido64, @krizzu, thanks for taking your time on this issue.

@tido64, I have only logs. They are coming from the Google automated tests, I think.

If that was addressed, as @krizzu said, I think we are done with this for now. I'm not experiencing any problems lately.

@limaAniceto
Copy link

limaAniceto commented Jan 11, 2021

Hi there @keeprock, @krizzu and @tido64 ,
I'd like to say I really appreciate everyone's work on this.

If it's not too much trouble, I'd like to share some more info on this issue.

I've recently bumped @react-native-async-storage/async-storage to 1.13.2 and I'm seeing this crash happen.

This is the log info that I can share:
Android v5.1.1
image

"react-native": "0.63.4",
"@react-native-async-storage/async-storage": "1.13.2",

I'll be going through this dependency's code and @krizzu's PR to see if I can figure it out, either way leaving this here for your eyes : )

PS: If I find more relevant info, I'll be updating this comment.

Thank you again,

@keeprock
Copy link
Author

keeprock commented Jan 11, 2021

Thanks @limaAniceto.

Could you be so kindly to show me, which version you've got prior to bumping? I'm looking for a stable version. Got some other error reports, which may be linked to this.

@limaAniceto
Copy link

Thanks @limaAniceto.

Could you, kindly, show to me, which version you've got prior to bumping? I'm looking for a stable version. Got some other error reports, which may be linked to this.

Thank you so much for getting back to me so quickly @keeprock

We were previously at "@react-native-community/async-storage": "1.11.0"

If there's anything else that I can find that helps you, please let me know 🙏

@saghul
Copy link

saghul commented Jan 12, 2021

Same here, we got this crash too, alas the tracebacks are not that helpful:

Fatal Exception: java.lang.RuntimeException: An error occurred while executing doInBackground()
       at android.os.AsyncTask$4.done(AsyncTask.java:399)
       at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:383)
       at java.util.concurrent.FutureTask.setException(FutureTask.java:252)
       at java.util.concurrent.FutureTask.run(FutureTask.java:271)
       at com.reactnativecommunity.asyncstorage.AsyncStorageModule$SerialExecutor$1.run(AsyncStorageModule.java:63)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
       at java.lang.Thread.run(Thread.java:919)

Caused by java.lang.IllegalStateException: attempt to re-open an already-closed object: SQLiteDatabase: /data/user/0/org.jitsi.meet/databases/RKStorage
       at android.database.sqlite.SQLiteClosable.acquireReference(SQLiteClosable.java:57)
       at android.database.sqlite.SQLiteDatabase.queryWithFactory(SQLiteDatabase.java:1809)
       at android.database.sqlite.SQLiteDatabase.query(SQLiteDatabase.java:1685)
       at android.database.sqlite.SQLiteDatabase.query(SQLiteDatabase.java:1853)
       at com.reactnativecommunity.asyncstorage.AsyncStorageModule$1.doInBackgroundGuarded(AsyncStorageModule.java:159)
       at com.reactnativecommunity.asyncstorage.AsyncStorageModule$1.doInBackgroundGuarded(AsyncStorageModule.java:146)
       at com.facebook.react.bridge.GuardedAsyncTask.doInBackground(GuardedAsyncTask.java:35)
       at com.facebook.react.bridge.GuardedAsyncTask.doInBackground(GuardedAsyncTask.java:19)
       at android.os.AsyncTask$3.call(AsyncTask.java:378)
       at java.util.concurrent.FutureTask.run(FutureTask.java:266)
       at com.reactnativecommunity.asyncstorage.AsyncStorageModule$SerialExecutor$1.run(AsyncStorageModule.java:63)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
       at java.lang.Thread.run(Thread.java:919)

Got these from Crashlytics, I don't know how to reproduce the issue.

@riyabhatti876
Copy link

what is the solution

@hubciorz
Copy link

Why is this closed?

@elgambet
Copy link

elgambet commented Apr 30, 2024

Still happening:

`
"react-native": "0.72.5",

"@react-native-async-storage/async-storage": "1.19.3",
`

@zyestin
Copy link

zyestin commented May 26, 2025

Still happening, when the App undergoes a hot update

"react-native": "0.73.6"
react-native-async-storage/async-storage    version "2.1.0"

crash reason

java.lang.RuntimeException: An error occurred while executing doInBackground() at android.os.AsyncTask$4.done(AsyncTask.java:415) at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:383) at java.util.concurrent.FutureTask.setException(FutureTask.java:252) at java.util.concurrent.FutureTask.run(FutureTask.java:271) at com.reactnativecommunity.asyncstorage.SerialExecutor$1.run(SerialExecutor.java:25) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) at java.lang.Thread.run(Thread.java:923) Caused by: java.lang.IllegalStateException: java.lang.IllegalStateException: attempt to re-open an already-closed object: SQLiteDatabase: /data/user/0/com.huabenapp/databases/RKStorage at com.facebook.react.bridge.ReactContext.handleException(ReactContext.java:478) at com.facebook.react.bridge.ReactContext$ExceptionHandlerWrapper.handleException(ReactContext.java:485) at com.facebook.$

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

No branches or pull requests

9 participants