I'm trying to update my redux store with data that was entered in my useState
.While I was researching this error logs, I've noticed that in most cases it is related to realm database, somehow it seems to affect my redux store even if I'm not trying to up my database.
LOG [Error: Wrong transactional state (no active transaction, wrong type of transaction, or transaction already in progress)Exception backtrace:<backtrace not supported on this platform>] ERROR Error: Wrong transactional state (no active transaction, wrong type of transaction, or transaction already in progress)Exception backtrace:<backtrace not supported on this platform>
my action ruction is as follows:
editEntity: (state, {payload}: any) => { let entity = state.businesses?.find(x => x.businessId?.equals(payload.businessId), ); if (entity) { entity.name = payload.name; } }
as you can see, all I'm updating is my redux state.
On the other hand when I create a new business object and save it to my realm database, I first create the object and check if my state array has any other business entities. If it has previous entities, they will all be set to false e.g isDefault: false
while the new entity will be set to true automatically. Below is the function I used to create an entity and check whether to set isDefault
to false || true
:
const addHandler = async () => { try { //first create the realm object realm.write(() => { realm.create('BusinessEntity', TBusiness.generate( business.accountingPeriodId!, business.name!, business.registrationNumber!, business.vatRegistered!, business.vatNumber!, business.startDate!, business.endDate!, business.streetAddress!, business.suburb!, business.province!, business.postalCode!, business.autoGenerateCustomerCode!, business.autoGenerateItemCode!, business.invoiceMessage!, business.quotationMessage!, business.bankName!, business.branchCode!, business.accountNumber!, business.accountName!, ), ); }); let newBusiness = await query.find(x => x.name === business.name); let businessObject = realm.objects(TBusiness); dispatch(addBusinessAction(newBusiness)); //update state, set previous to false if (businessArray.businesses!.length > 0) { //update any business entity that was created to "false" //businessObject.findIndex(x => { // //if (x.name !== business.name) { //x.isDefault = false; //} //}); businessObject.forEach(x => { if (x.name !== business.name) { return (x.isDefault = false); } }); } setBusiness({}); } catch (err) { console.log(err); throw err; } };
But when I run the function, I get the following logs:
LOG [Error: Wrong transactional state (no active transaction, wrong type of transaction, or transaction already in progress)Exception backtrace:0 Numberz 0x00000001053aca9f _ZN5realm10LogicErrorC1ENS0_9ErrorKindE + 471 Numberz 0x000000010577f472 _ZN5realm4Node16do_copy_on_writeEm + 3542 Numberz 0x00000001056bc497 _ZN5realm5Array3setEmx + 1033 Numberz 0x000000010577fadd _ZN5realm3Obj3setIbEERS0_NS_6ColKeyET_b + 6374 Numberz 0x00000001053ba358 _ZN5realm6Object23set_property_value_implIPK13OpaqueJSValueNS_2js14NativeAccessorINS_3jsc5TypesEEEEEvRT0_RKNS_8PropertyET_NS_12CreatePolicyEb + 35925 Numberz 0x00000001053d6fa8 _ZN5realm2js16RealmObjectClassINS_3jsc5TypesEE12set_propertyEPK15OpaqueJSContextP13OpaqueJSValueRKNS0_6StringIS3_EEPKS8_ + 5046 Numberz 0x0000000105435068 _ZN5realm2js4wrapIXadL_ZNS0_16RealmObjectClassINS_3jsc5TypesEE12set_propertyEPK15OpaqueJSContextP13OpaqueJSValueRKNS0_6StringIS4_EEPKS9_EEEEbS8_SA_P14OpaqueJSStringSG_PSG_ + 567 Numberz 0x000000010543e5e5 _ZN5realm3jsc10ObjectWrapINS_2js16RealmObjectClassINS0_5TypesEEEE15accessor_setterEPK15OpaqueJSContextP13OpaqueJSValueSB_mPKPKSA_PSD_ + 538 JavaScriptCore 0x00007fff318abd63 _ZN3JSC16JSCallbackObjectINS_16JSNonFinalObjectEE4callEPNS_14JSGlobalObjectEPNS_9CallFrameE + 6279 JavaScriptCore 0x00007fff31836021 vmEntryToNative + 22610 JavaScriptCore 0x00007fff31ee2c1d _ZN3JSC11Interpreter11executeCallEPNS_14JSGlobalObjectEPNS_8JSObjectERKNS_8CallDataENS_7JSValueERKNS_7ArgListE + 57311 JavaScriptCore 0x00007fff321a18f4 _ZN3JSC10callSetterEPNS_14JSGlobalObjectENS_7JSValueES2_S2_NS_8ECMAModeE + 30812 JavaScriptCore 0x00007fff32249625 _ZN3JSC8JSObject13putInlineSlowEPNS_14JSGlobalObjectENS_12PropertyNameENS_7JSValueERNS_15PutPropertySlotE + 107713 JavaScriptCore 0x00007fff31fd9fb4 llint_slow_path_put_by_id + 125214 JavaScriptCore 0x00007fff3183f8cd llint_entry + 3892115 JavaScriptCore 0x00007fff3184f8c9 llint_entry + 10445316 JavaScriptCore 0x00007fff3184f949 llint_entry + 10458117 JavaScriptCore 0x00007fff3184f8c9 llint_entry + 10445318 ??? 0x0000507ac899f7ae 0x0 + 8848828176580619 JavaScriptCore 0x00007fff3184f8c9 llint_entry + 10445320 JavaScriptCore 0x00007fff3184f8c9 llint_entry + 10445321 JavaScriptCore 0x00007fff3184f8c9 llint_entry + 10445322 JavaScriptCore 0x00007fff3184f8c9 llint_entry + 10445323 JavaScriptCore 0x00007fff3184f949 llint_entry + 10458124 JavaScriptCore 0x00007fff3184f949 llint_entry + 10458125 JavaScriptCore 0x00007fff3184f8c9 llint_entry + 10445326 JavaScriptCore 0x00007fff3184f949 llint_entry + 10458127 JavaScriptCore 0x00007fff3184f8c9 llint_entry + 10445328 JavaScriptCore 0x00007fff3184f949 llint_entry + 10458129 JavaScriptCore 0x00007fff3184f949 llint_entry + 10458130 JavaScriptCore 0x00007fff3184f8c9 llint_entry + 10445331 JavaScriptCore 0x00007fff318509b1 llint_entry + 10878132 JavaScriptCore 0x00007fff3184f949 llint_entry + 10458133 ??? 0x0000507ac8ab4ac3 0x0 + 8848828290118734 JavaScriptCore 0x00007fff3184f8c9 llint_entry + 10445335 ??? 0x0000507ac8ab524f 0x0 + 8848828290311936 ??? 0x0000507ac8a9fa5b 0x0 + 8848828281506737 ??? 0x0000507ac86f2feb 0x0 + 8848827896215538 ??? 0x0000507ac8a9f0e9 0x0 + 8848828281264939 ??? 0x0000507ac86025d7 0x0 + 8848827797653540 JavaScriptCore 0x00007fff31835ecf vmEntryToJavaScript + 21641 JavaScriptCore 0x00007fff31ee2be6 _ZN3JSC11Interpreter11executeCallEPNS_14JSGlobalObjectEPNS_8JSObjectERKNS_8CallDataENS_7JSValueERKNS_7ArgListE + 51842 JavaScriptCore 0x00007fff321e66b7 _ZN3JSC27boundThisNoArgsFunctionCallEPNS_14JSGlobalObjectEPNS_9CallFrameE + 74343 JavaScriptCore 0x00007fff31836021 vmEntryToNative + 22644 JavaScriptCore 0x00007fff31ee2c1d _ZN3JSC11Interpreter11executeCallEPNS_14JSGlobalObjectEPNS_8JSObjectERKNS_8CallDataENS_7JSValueERKNS_7ArgListE + 57345 JavaScriptCore 0x00007fff32135714 _ZN3JSC12profiledCallEPNS_14JSGlobalObjectENS_15ProfilingReasonENS_7JSValueERKNS_8CallDataES3_RKNS_7ArgListE + 16446 JavaScriptCore 0x00007fff318b9706 JSObjectCallAsFunction + 69447 Numberz 0x00000001052ae838 _ZN8facebook3jsc10JSCRuntime4callERKNS_3jsi8FunctionERKNS2_5ValueEPS7_m + 34448 Numberz 0x00000001052bea5d _ZNK8facebook3jsi8Function4callERNS0_7RuntimeEPKNS0_5ValueEm + 12549 Numberz 0x00000001052be97b _ZNK8facebook3jsi8Function4callERNS0_7RuntimeESt16initializer_listINS0_5ValueEE + 10750 Numberz 0x00000001052e1890 _ZNK8facebook3jsi8Function4callIJRKNSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEESB_NS0_5ValueEEEESC_RNS0_7RuntimeEDpOT_ + 36851 Numberz 0x00000001052e16b6 _ZZN8facebook5react11JSIExecutor12callFunctionERKNSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEESA_RKN5folly7dynamicEENK3$_5clEv + 16652 Numberz 0x00000001052e15ed _ZNSt3__1L8__invokeIRZN8facebook5react11JSIExecutor12callFunctionERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEESB_RKN5folly7dynamicEE3$_5JEEEDTclclsr3std3__1E7forwardIT_Efp_Espclsr3std3__1E7forwardIT0_Efp0_EEEOSI_DpOSJ_ + 2953 Numberz 0x00000001052e159d _ZNSt3__128__invoke_void_return_wrapperIvE6__callIJRZN8facebook5react11JSIExecutor12callFunctionERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEESD_RKN5folly7dynamicEE3$_5EEEvDpOT_ + 2954 Numberz 0x00000001052e156d _ZNSt3__110__function12__alloc_funcIZN8facebook5react11JSIExecutor12callFunctionERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEESC_RKN5folly7dynamicEE3$_5NS8_ISH_EEFvvEEclEv + 2955 Numberz 0x00000001052e049e _ZNSt3__110__function6__funcIZN8facebook5react11JSIExecutor12callFunctionERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEESC_RKN5folly7dynamicEE3$_5NS8_ISH_EEFvvEEclEv + 3056 Numberz 0x0000000105321f85 _ZNKSt3__110__function12__value_funcIFvvEEclEv + 5357 Numberz 0x0000000105321e95 _ZNKSt3__18functionIFvvEEclEv + 2158 Numberz 0x0000000104ffe2f9 _ZN8facebook5react11JSIExecutor21defaultTimeoutInvokerERKNSt3__18functionIFvvEEENS3_IFNS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEvEEE + 2559 Numberz 0x0000000105000ccc _ZNSt3__1L8__invokeIRPFvRKNS_8functionIFvvEEENS1_IFNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEvEEEEJS5_SD_EEEDTclclsr3std3__1E7forwardIT_Efp_Espclsr3std3__1E7forwardIT0_Efp0_EEEOSH_DpOSI_ + 10860 Numberz 0x0000000105000c37 _ZNSt3__128__invoke_void_return_wrapperIvE6__callIJRPFvRKNS_8functionIFvvEEENS3_IFNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEvEEEES7_SF_EEEvDpOT_ + 7161 Numberz 0x0000000105000bc7 _ZNSt3__110__function12__alloc_funcIPFvRKNS_8functionIFvvEEENS2_IFNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEvEEEENSA_ISG_EESF_EclES6_OSE_ + 7162 Numberz 0x0000000104fff7c8 _ZNSt3__110__function6__funcIPFvRKNS_8functionIFvvEEENS2_IFNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEvEEEENSA_ISG_EESF_EclES6_OSE_ + 7263 Numberz 0x00000001052dfaba _ZNKSt3__110__function12__value_funcIFvRKNS_8functionIFvvEEENS2_IFNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEvEEEEEclES6_OSE_ + 10664 Numberz 0x00000001052cf825 _ZNKSt3__18functionIFvRKNS0_IFvvEEENS0_IFNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEvEEEEEclES4_SC_ + 6965 Numberz 0x00000001052cf46b _ZN8facebook5react11JSIExecutor12callFunctionERKNSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEESA_RKN5folly7dynamicE + 49166 Numberz 0x0000000105295363 _ZZN8facebook5react16NativeToJsBridge12callFunctionEONSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEES9_ON5folly7dynamicEENK3$_2clEPNS0_10JSExecutorE + 73967 Numberz 0x0000000105295062 _ZNSt3__1L8__invokeIRZN8facebook5react16NativeToJsBridge12callFunctionEONS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEESA_ON5folly7dynamicEE3$_2JPNS2_10JSExecutorEEEEDTclclsr3std3__1E7forwardIT_Efp_Espclsr3std3__1E7forwardIT0_Efp0_EEEOSI_DpOSJ_ + 5068 Numberz 0x0000000105295002 _ZNSt3__128__invoke_void_return_wrapperIvE6__callIJRZN8facebook5react16NativeToJsBridge12callFunctionEONS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEESC_ON5folly7dynamicEE3$_2PNS4_10JSExecutorEEEEvDpOT_ + 5069 Numberz 0x0000000105294fc2 _ZNSt3__110__function12__alloc_funcIZN8facebook5react16NativeToJsBridge12callFunctionEONS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEESB_ON5folly7dynamicEE3$_2NS8_ISF_EEFvPNS3_10JSExecutorEEEclEOSI_ + 5070 Numberz 0x0000000105293c43 _ZNSt3__110__function6__funcIZN8facebook5react16NativeToJsBridge12callFunctionEONS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEESB_ON5folly7dynamicEE3$_2NS8_ISF_EEFvPNS3_10JSExecutorEEEclEOSI_ + 5171 Numberz 0x00000001052a05dd _ZNKSt3__110__function12__value_funcIFvPN8facebook5react10JSExecutorEEEclEOS5_ + 7772 Numberz 0x00000001052a0560 _ZNKSt3__18functionIFvPN8facebook5react10JSExecutorEEEclES4_ + 4873 Numberz 0x00000001052a0528 _ZZN8facebook5react16NativeToJsBridge18runOnExecutorQueueENSt3__18functionIFvPNS0_10JSExecutorEEEEENK3$_8clEv + 10474 Numberz 0x00000001052a049d _ZNSt3__1L8__invokeIRZN8facebook5react16NativeToJsBridge18runOnExecutorQueueENS_8functionIFvPNS2_10JSExecutorEEEEE3$_8JEEEDTclclsr3std3__1E7forwardIT_Efp_Espclsr3std3__1E7forwardIT0_Efp0_EEEOSB_DpOSC_ + 2975 Numberz 0x00000001052a044d _ZNSt3__128__invoke_void_return_wrapperIvE6__callIJRZN8facebook5react16NativeToJsBridge18runOnExecutorQueueENS_8functionIFvPNS4_10JSExecutorEEEEE3$_8EEEvDpOT_ + 2976 Numberz 0x00000001052a041d _ZNSt3__110__function12__alloc_funcIZN8facebook5react16NativeToJsBridge18runOnExecutorQueueENS_8functionIFvPNS3_10JSExecutorEEEEE3$_8NS_9allocatorISA_EEFvvEEclEv + 2977 Numberz 0x000000010529ef7e _ZNSt3__110__function6__funcIZN8facebook5react16NativeToJsBridge18runOnExecutorQueueENS_8functionIFvPNS3_10JSExecutorEEEEE3$_8NS_9allocatorISA_EEFvvEEclEv + 3078 Numberz 0x0000000105321f85 _ZNKSt3__110__function12__value_funcIFvvEEclEv + 5379 Numberz 0x0000000105321e95 _ZNKSt3__18functionIFvvEEclEv + 2180 Numberz 0x0000000105060cd5 _ZN8facebook5react17tryAndReturnErrorERKNSt3__18functionIFvvEEE + 2181 Numberz 0x00000001050928b1 _ZN8facebook5react16RCTMessageThread7tryFuncERKNSt3__18functionIFvvEEE + 3382 Numberz 0x00000001050981ce _ZZN8facebook5react16RCTMessageThread10runOnQueueEONSt3__18functionIFvvEEEENK3$_1clEv + 9483 Numberz 0x000000010509814d _ZNSt3__1L8__invokeIRZN8facebook5react16RCTMessageThread10runOnQueueEONS_8functionIFvvEEEE3$_1JEEEDTclclsr3std3__1E7forwardIT_Efp_Espclsr3std3__1E7forwardIT0_Efp0_EEEOSA_DpOSB_ + 2984 Numberz 0x00000001050980fd _ZNSt3__128__invoke_void_return_wrapperIvE6__callIJRZN8facebook5react16RCTMessageThread10runOnQueueEONS_8functionIFvvEEEE3$_1EEEvDpOT_ + 2985 Numberz 0x00000001050980cd _ZNSt3__110__function12__alloc_funcIZN8facebook5react16RCTMessageThread10runOnQueueEONS_8functionIFvvEEEE3$_1NS_9allocatorIS9_EES6_EclEv + 2986 Numberz 0x0000000105096d3e _ZNSt3__110__function6__funcIZN8facebook5react16RCTMessageThread10runOnQueueEONS_8functionIFvvEEEE3$_1NS_9allocatorIS9_EES6_EclEv + 3087 Numberz 0x0000000105321f85 _ZNKSt3__110__function12__value_funcIFvvEEclEv + 5388 Numberz 0x0000000105321e95 _ZNKSt3__18functionIFvvEEclEv + 2189 Numberz 0x0000000105092510 ___ZN8facebook5react16RCTMessageThread8runAsyncENSt3__18functionIFvvEEE_block_invoke + 4890 CoreFoundation 0x00007fff20390120 __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 1291 CoreFoundation 0x00007fff2038f534 __CFRunLoopDoBlocks + 43492 CoreFoundation 0x00007fff20389f44 __CFRunLoopRun + 89993 CoreFoundation 0x00007fff203896d6 CFRunLoopRunSpecific + 56794 Numberz 0x000000010502b891 +[RCTCxxBridge runRunLoop] + 99395 Foundation 0x00007fff20858e68 __NSThread__start__ + 104296 libsystem_pthread.dylib 0x00007fff61167109 _pthread_start + 14897 libsystem_pthread.dylib 0x00007fff61162b8b thread_start + 15] WARN Possible Unhandled Promise Rejection (id: 3):Error: Wrong transactional state (no active transaction, wrong type of transaction, or transaction already in progress)Exception backtrace:0 Numberz 0x00000001053aca9f _ZN5realm10LogicErrorC1ENS0_9ErrorKindE + 471 Numberz 0x000000010577f472 _ZN5realm4Node16do_copy_on_writeEm + 3542 Numberz 0x00000001056bc497 _ZN5realm5Array3setEmx + 1033 Numberz 0x000000010577fadd _ZN5realm3Obj3setIbEERS0_NS_6ColKeyET_b + 6374 Numberz 0x00000001053ba358 _ZN5realm6Object23set_property_value_implIPK13OpaqueJSValueNS_2js14NativeAccessorINS_3jsc5TypesEEEEEvRT0_RKNS_8PropertyET_NS_12CreatePolicyEb + 35925 Numberz 0x00000001053d6fa8 _ZN5realm2js16RealmObjectClassINS_3jsc5TypesEE12set_propertyEPK15OpaqueJSContextP13OpaqueJSValueRKNS0_6StringIS3_EEPKS8_ + 5046 Numberz 0x0000000105435068 _ZN5realm2js4wrapIXadL_ZNS0_16RealmObjectClassINS_3jsc5TypesEE12set_propertyEPK15OpaqueJSContextP13OpaqueJSValueRKNS0_6StringIS4_EEPKS9_EEEEbS8_SA_P14OpaqueJSStringSG_PSG_ + 567 Numberz 0x000000010543e5e5 _ZN5realm3jsc10ObjectWrapINS_2js16RealmObjectClassINS0_5TypesEEEE15accessor_setterEPK15OpaqueJSContextP13OpaqueJSValueSB_mPKPKSA_PSD_ + 538 JavaScriptCore 0x00007fff318abd63 _ZN3JSC16JSCallbackObjectINS_16JSNonFinalObjectEE4callEPNS_14JSGlobalObjectEPNS_9CallFrameE + 6279 JavaScriptCore 0x00007fff31836021 vmEntryToNative + 22610 JavaScriptCore 0x00007fff31ee2c1d _ZN3JSC11Interpreter11executeCallEPNS_14JSGlobalObjectEPNS_8JSObjectERKNS_8CallDataENS_7JSValueERKNS_7ArgListE + 57311 JavaScriptCore 0x00007fff321a18f4 _ZN3JSC10callSetterEPNS_14JSGlobalObjectENS_7JSValueES2_S2_NS_8ECMAModeE + 30812 JavaScriptCore 0x00007fff32249625 _ZN3JSC8JSObject13putInlineSlowEPNS_14JSGlobalObjectENS_12PropertyNameENS_7JSValueERNS_15PutPropertySlotE + 107713 JavaScriptCore 0x00007fff31fd9fb4 llint_slow_path_put_by_id + 125214 JavaScriptCore 0x00007fff3183f8cd llint_entry + 3892115 JavaScriptCore 0x00007fff3184f8c9 llint_entry + 10445316 JavaScriptCore 0x00007fff3184f949 llint_entry + 10458117 JavaScriptCore 0x00007fff3184f8c9 llint_entry + 10445318 ??? 0x0000507ac899f7ae 0x0 + 8848828176580619 JavaScriptCore 0x00007fff3184f8c9 llint_entry + 10445320 JavaScriptCore 0x00007fff3184f8c9 llint_entry + 10445321 JavaScriptCore 0x00007fff3184f8c9 llint_entry + 10445322 JavaScriptCore 0x00007fff3184f8c9 llint_entry + 10445323 JavaScriptCore 0x00007fff3184f949 llint_entry + 10458124 JavaScriptCore 0x00007fff3184f949 llint_entry + 10458125 JavaScriptCore 0x00007fff3184f8c9 llint_entry + 10445326 JavaScriptCore 0x00007fff3184f949 llint_entry + 10458127 JavaScriptCore 0x00007fff3184f8c9 llint_entry + 10445328 JavaScriptCore 0x00007fff3184f949 llint_entry + 10458129 JavaScriptCore 0x00007fff3184f949 llint_entry + 10458130 JavaScriptCore 0x00007fff3184f8c9 llint_entry + 10445331 JavaScriptCore 0x00007fff318509b1 llint_entry + 10878132 JavaScriptCore 0x00007fff3184f949 llint_entry + 10458133 ??? 0x0000507ac8ab4ac3 0x0 + 8848828290118734 JavaScriptCore 0x00007fff3184f8c9 llint_entry + 10445335 ??? 0x0000507ac8ab524f 0x0 + 8848828290311936 ??? 0x0000507ac8a9fa5b 0x0 + 8848828281506737 ??? 0x0000507ac86f2feb 0x0 + 8848827896215538 ??? 0x0000507ac8a9f0e9 0x0 + 8848828281264939 ??? 0x0000507ac86025d7 0x0 + 8848827797653540 JavaScriptCore 0x00007fff31835ecf vmEntryToJavaScript + 21641 JavaScriptCore 0x00007fff31ee2be6