React Native NCW SDK - Recovery Issue: No callback found for operation

Hi,

We are running into issues with the React Native NCW SDK on Android.

This is the relevant code extracted from our project:

const passphrase = await gdriveRecover({
  token: accessToken,
  passphraseId: googleDrivePassphrase.uuid
});

if (!passphrase) {
  throw new Error('No passphrase found for the given ID.');
}

// Callback function that returns the passphrase
const passphraseResolver = async (passphraseId: string): Promise<string> => {
  console.log('Passphrase callback was called with ID:', passphraseId);
  return passphrase;
};
const result = sdk.recoverKeys(passphraseResolver);
console.log('Recover keys result:', result);

Recovery is running perfectly on iOS with the exact same code, but on Android it throws the following error:

 (NOBRIDGE) DEBUG  gdrive getting file... 1MleRNe7TubdXNl05UhJP6j63ADRSwBsZsbfBzDT3v9hvdx7ljQ
 (NOBRIDGE) DEBUG  outgoingMessage called! {"deviceId": "aaa03fd4-4460-4dec-9046-7cc3b2e173de", "opId": 36}
 (NOBRIDGE) LOG  baseUrl https://fireblocks-testnet.services.rehive.com/api/ncw
 (NOBRIDGE) LOG  path api/devices/aaa03fd4-4460-4dec-9046-7cc3b2e173de/rpc
 (NOBRIDGE) LOG  body {"message": "{\"headers\":{\"physicalDeviceId\":\"8468ee93-5a22-42ce-a774-e9aac8803f09\",\"platformType\":\"Android\",\"sdkVersion\":\"2.9.1.173\",\"mpcVersion\":\"6\"},\"method\":\"get_backup\",\"params\":[]}"}
 (NOBRIDGE) ERROR  outgoingMessage error [Error: No callback found for operation 36]
 (NOBRIDGE) WARN  Possible Unhandled Promise Rejection (id: 0):
Error: No callback found for operation 36
 (NOBRIDGE) DEBUG  sdk_event called! {"keyDescriptor": {"algorithm": "null", "keyId": null, "keyStatus": "ERROR"}, "type": "keys_recovery"}
 (NOBRIDGE) LOG  Recover keys result: undefined

This is when running in the Android Simulator: Pixel 9 API 35. See screen recording below:
short-recovery-failure

On the older Pixel 3 API 33 simulator and some physical android, we get similar callback errors even for the backup flow (not only recovery). Both backup and recovery run fine with the same code on iOS.

This is with

dependencies {
    implementation "com.fireblocks.sdk:ncw:2.9.1"
    ...
}

Hello,

Please provide more information - on how you create/initialize the SDK? are you using more than one SDK instance?
please share the code here.

Hi @golan,

We’re initializing only one SDK instance and are initializing it with the following code:

      const secureStorageProvider = new EncryptedSecureStorage(deviceId);

      const messagesHandler = {
        handleOutgoingMessage: (message: string) => {
          if (!deviceId) throw new Error("Device ID not set");
          if (!authUser.token) throw new Error("Authentication token not available");
          return apiService.sendMessage({ deviceId: deviceId, message: message, token: authUser.token });
        },
      };

      const eventsHandler = {
        handleEvent: (event: TEvent) => {
          switch (event.type) {
            case "key_descriptor_changed":
              setKeysStatus((prevStatus) => 
                prevStatus ? {
                  ...prevStatus,
                  [event.keyDescriptor.algorithm]: event.keyDescriptor,
                } : null
              );
              break;
          }
        },
      };

      const newSdk = await FireblocksNCWFactory({
        env: (process.env.EXPO_PUBLIC_NCW_SDK_ENV as TEnv) || 'sandbox',
        logLevel: "INFO",
        deviceId,
        messagesHandler,
        eventsHandler,
        secureStorageProvider,
      });

However, when I ran the same test today on the exact same build (with SDK 2.9.1), suddenly the error is no longer occurring.

Is it possible something changed on your backend for the sandbox environment? Because previously recovery was consistently failing for Android and now at least in my last three tests it is succeeding.