The Realm is already in a write transaction
See original GitHub issueI’m getting an error when writing to a Realm db. I’ve looked at other solutions for this, and the recommended approach to checking if in a write transaction doesn’t seem to be available in Realm JS. Is there some other mechanism to address this? Thanks!
Here’s the offending code:
addAll: Function = (businessesToAdd): ?Array<Business> => {
let businesses: Array<Business> = [];
Realm.write(() => {
businesses = businessesToAdd.map(business => {
return Realm.create(ClassName, { ...business }, true);
});
});
return businesses;
};
ExceptionsManager.js:71 Error: The Realm is already in a write transaction
at sendRequest (http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=false&minify=false:130302:7)
at Object.callMethod (http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=false&minify=false:130220:1784)
at Realm.<anonymous> (http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=false&minify=false:130063:771)
at BusinessDAO.exports.BusinessDAO.addAll (http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=false&minify=false:137351:17)
at _callee$ (http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=false&minify=false:137464:23)
at tryCatch (http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=false&minify=false:26695:29)
at Generator.invoke [as _invoke] (http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=false&minify=false:26969:12)
at Generator.prototype.(anonymous function) [as next] (http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=false&minify=false:26728:13)
at tryCatch (http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=false&minify=false:26695:29)
at invoke (http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=false&minify=false:26771:12)
Issue Analytics
- State:
- Created 6 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
the realm is already in a write transaction - Stack Overflow
The rule of thumb for Realm is only one write transaction open on an RLMRealm at any given time.
Read more >Realm is already in write transaction · Issue #6215 - GitHub
I am using below method to write in DB, but sometimes getting random issue "The Realm is already in a write transaction in ......
Read more >Already in write transaction at stress test - Realm - MongoDB
I'm confuse with a behaviour im observing at realm (swift). So from beginning, I got this error. Fatal error: 'try!' expression unexpectedly ...
Read more >[Fixed]-the realm is already in a write transaction-objective-c
The rule of thumb for Realm is only one write transaction open on an RLMRealm at any given time. You might need to...
Read more >Objective-c – the realm is already in a write transaction
How can i avoid this error? is there a way to check realm is in write traction? if realm is in write transaction...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@blagoev As a followup, we do not have any nested
.write
blocks, and it doesn’t seem like the issue is fixed as per #127 .Are there any steps we can take to debug into this a bit more?
We have added manual transactions to help in this situation. I hope we can release it this week.