You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When autosave is used with sqljs and localforage, sometimes there is an error with the message 'cannot commit - no transaction is active. As far as I can tell, it happens when two or more write-requests are made at the same time. Both start, then the first one ends, the autosave is called. The autosave exports the sqljs-database, which closes the transaction silently. Then the second one ends and tries to close the connection, which is not open anymore. Therefore the error is thrown.
Potentially can this resolve in an unwanted state. If I try to save A & B in separate repositories and B has a dependency C, which must also be saved, then it can happen, that A & B are saved, then the DB is exported, tries to save C, but there is an error in C, such that it tries to rollback the transaction containing B & C. But there is no transaction anymore, which means that the changes in B are saved, but not the one in C and therefore the data is not correct.
Expected Behavior
Call autosave only when no transaction is active in order to not run into errors
Actual Behavior
Steps to Reproduce
My Environment
Dependency
Version
Operating System
Browser
Brave/Chrome
Typescript version
4.6.3
TypeORM version
0.3.5
sql.js
1.7.0
localforage
1.10.0
Relevant Database Driver(s)
DB Type
Reproducible
aurora-mysql
no
aurora-postgres
no
better-sqlite3
no
cockroachdb
no
cordova
no
expo
no
mongodb
no
mysql
no
nativescript
no
oracle
no
postgres
no
react-native
no
sap
no
spanner
no
sqlite
no
sqlite-abstract
no
sqljs
yes
sqlserver
no
Are you willing to resolve this issue by submitting a Pull Request?
✅ Yes, I have the time, and I know how to start.
✖️ Yes, I have the time, but I don't know how to start. I would need guidance.
✖️ No, I don’t have the time, but I can support (using donations) development.
✖️ No, I don’t have the time and I’m okay to wait for the community / maintainers to resolve this issue.
The text was updated successfully, but these errors were encountered:
* fix: fix "Cannot commit, no transaction is active" error in sql.js
Closes: #9100
* Flush database only if transaction is done
Co-authored-by: Brice Miclo <brice.miclo@socomec.com>
Issue Description
When autosave is used with sqljs and localforage, sometimes there is an error with the message
'cannot commit - no transaction is active
. As far as I can tell, it happens when two or more write-requests are made at the same time. Both start, then the first one ends, the autosave is called. The autosave exports the sqljs-database, which closes the transaction silently. Then the second one ends and tries to close the connection, which is not open anymore. Therefore the error is thrown.Potentially can this resolve in an unwanted state. If I try to save A & B in separate repositories and B has a dependency C, which must also be saved, then it can happen, that A & B are saved, then the DB is exported, tries to save C, but there is an error in C, such that it tries to rollback the transaction containing B & C. But there is no transaction anymore, which means that the changes in B are saved, but not the one in C and therefore the data is not correct.
Expected Behavior
Call autosave only when no transaction is active in order to not run into errors
Actual Behavior
Steps to Reproduce
My Environment
Relevant Database Driver(s)
aurora-mysql
aurora-postgres
better-sqlite3
cockroachdb
cordova
expo
mongodb
mysql
nativescript
oracle
postgres
react-native
sap
spanner
sqlite
sqlite-abstract
sqljs
sqlserver
Are you willing to resolve this issue by submitting a Pull Request?
The text was updated successfully, but these errors were encountered: