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

"Illegal callback invocation from native module." on syncDown #163

Open
jpmonette opened this issue Feb 19, 2020 · 11 comments
Open

"Illegal callback invocation from native module." on syncDown #163

jpmonette opened this issue Feb 19, 2020 · 11 comments
Labels

Comments

@jpmonette
Copy link
Contributor

jpmonette commented Feb 19, 2020

Describe the bug
When I try to create a new syncDown following registering soup, deleting soup, and registering soup, the app turns into an unrecoverable state (and cannot catch error):

Illegal callback invocation from native module. This callback type only permits a single invocation from native code.

To Reproduce
Steps to reproduce the behavior:

// Promise-fying calls + importing salesforce-queries

const sobject = 'Account';
const indexSpecs = ['Id']

const target = {
  type: 'soql',
  query: new SOQL(sobject)
    .select(indexSpecs)
    .limit(10000)
    .build(),
};

const options = { mergeMode: mobileSync.MERGE_MODE.OVERWRITE };

await smartStore.registerSoup(false, sobject, indexSpecs)
await mobileSync.syncDown(false, target, sobject, options, sobject)
await mobileSync.deleteSync(false, sobject)
await smartStore.removeAllStores()
await smartStore.registerSoup(false, sobject, indexSpecs)
await mobileSync.syncDown(false, target, sobject, options, sobject) // boom! 💥

This will throw error + prevent to call syncDown successfully again. Only way is to stop the application + re-build.

Expected behavior
Step 6 would allow to run syncDown successfully.

Actual behavior
Steps 6 returns:

Illegal callback invocation from native module. This callback type only permits a single invocation from native code.

Versions (please complete the following information):

  • v8.1.0

Trace

RCTFatal
checkCallbackMultipleInvocations(bool*)
__41-[RCTModuleMethod processMethodSignature]_block_invoke_2.106
-[SFMobileSyncReactBridge handleSyncUpdate:withArgs:callback:]
__45-[SFMobileSyncReactBridge syncDown:callback:]_block_invoke
__113-[SFMobileSyncSyncManager(Instrumentation) instr_syncDownWithTarget:options:soupName:syncName:updateBlock:error:]_block_invoke
-[SFSyncTask updateSync:countSynched:]
-[SFAdvancedSyncUpTask syncUpMultipleEntries:recordIds:index:batch:]
-[SFAdvancedSyncUpTask syncUp:recordIds:]
-[SFSyncUpTask runSync:]
-[SFSyncTask run]
__47-[SFMobileSyncSyncManager runSync:updateBlock:]_block_invoke
_dispatch_call_block_and_release
_dispatch_client_callout
_dispatch_lane_serial_drain
_dispatch_lane_invoke
_dispatch_workloop_worker_thread
_pthread_wqthread
start_wqthread
@wmathurin
Copy link
Contributor

What version of the Mobile SDK are you running on?

@jpmonette
Copy link
Contributor Author

@wmathurin v8.1.0

@wmathurin
Copy link
Contributor

I would not call removeAllStores (it deletes all the databases).
You could just call removeSoup to drop the sobject soup.

@jpmonette
Copy link
Contributor Author

How is removeAllStores used then? It seems like it would forever prevent to call syncDown if it's used.

@wmathurin
Copy link
Contributor

removeAllStores wipes everything, including "system" tables that mobile sync relies on. We call it at logout to make sure nothing that belonged to the user was left behind.

@aureosouza
Copy link

@wmathurin We are getting the same error after logout and login with different user then logging with first user again in iOS. It seems that the method from native module syncDown is trying to reuse the same callback, which is forbidden by react native doc:

each callback can only be invoked at most one time. A native module can, however, store the callback and invoke it later.

We tried to call removeAllStores on logout but it doesn't help. Would be really good if we could have a guide of which functions are recommended to be called on logout to guarantee any inconsistencies when logging in again. An alternative to callbacks are events which could potentially solve the issue as well.

@wmathurin wmathurin reopened this Feb 3, 2021
@wmathurin wmathurin added the bug label Feb 4, 2021
@thiagomouraflima
Copy link

When do you intend to fix this bug?

@aureosouza
Copy link

@wmathurin any updates on this? Still have issue as well, thanks!

@va1bhav
Copy link

va1bhav commented Nov 10, 2022

@wmathurin @bhariharan could you please check if you can prioritise this bug into a release? This issue still exists in SDK 10.1.1. Thank you!

@MoinJanjua12
Copy link

HI GUYZ
I am also facing the same issue Upon clearing the cache, specifically by removing all stored data and subsequently starting the application, I consistently encounter the following error:
"Illegal callback invocation from native module. This callback type only permits a single invocation from native code."
this issue only occurs when I navigate the user to the start screen if I restart the app then its work fine
any one find any solution?

@wmathurin
Copy link
Contributor

We recommend you stop any running sync before logging out or removing soups or stores.
For more information see https://developer.salesforce.com/docs/platform/mobile-sdk/guide/entity-framework-stop-start-sync-operations.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants