Receiving error when invoking firebase.dynamicLinks().buildLink as follows: "Invariant Violation: No callback found with cbID XXXXX and callID XXXXX for RNFBDynamicLinksModule.buildLink - most likely the callback was already invoked. Args: '[]'"
Describe your issue here
Code in react-native was working previously, and had to switch Xcode build machines (due to loss of hard drive) now the build works, however buildLink fails consistently. All configurations and code restored from backup.
Error appears to occur on first call to build link, and triggers twice. Please see the attached image with complete error message.

import firebase from '@react-native-firebase/app';
import '@react-native-firebase/dynamic-links';
link = await firebase.dynamicLinks().buildLink({
link: https://${this.state.google_dyn_link_url_scheme}/?route=lnk&source=pass,
domainUriPrefix: https://${this.state.google_dyn_link_url_scheme},
ios: {
bundleId: this.state.bundle_id,
appStoreId: this.state.app_store_id,
minimumVersion: '9',
}
}
);
Click To Expand
#### `package.json`: { "name": "myAppName", "version": "1.5.1", "private": true, "scripts": { "android": "react-native run-android", "ios": "react-native run-ios", "start": "react-native start", "test": "jest", "lint": "eslint .", "flow": "flow", "clear": "./scripts/clear.sh", "build:ios": "react-native bundle --entry-file='index.js' --bundle-output='./ios/main.jsbundle' --dev=false --platform='ios'" }, "dependencies": { "@react-native-community/async-storage": "^1.7.1", "@react-native-community/datetimepicker": "^2.1.0", "@react-native-community/netinfo": "^3.2.1", "@react-native-firebase/app": "^6.3.4", "@react-native-firebase/auth": "^6.3.4", "@react-native-firebase/dynamic-links": "^6.3.4", "@react-native-firebase/firestore": "^6.3.4", "@react-native-firebase/functions": "^6.3.4", "babel-plugin-transform-remove-console": "^6.9.4", "core-js": "^3.4.7", "dot-prop-immutable": "^1.5.0", "lodash": "^4.17.15", "react": "16.9.0", "react-art": "^16.3.2", "react-dom": "^16.3.2", "react-native": "0.61.5", "react-native-awesome-card-io": "^0.8.2", "react-native-config": "^0.12.0", "react-native-credit-card-input": "^0.4.1", "react-native-datepicker": "^1.7.2", "react-native-deep-link": "^0.2.8", "react-native-dismiss-keyboard": "^1.0.0", "react-native-email": "^1.0.2", "react-native-email-link": "^1.4.0", "react-native-gesture-handler": "^1.2.2", "react-native-mail": "^3.0.7", "react-native-picker-select": "^6.0.0", "react-native-unified-contacts": "^1.6.2", "react-native-vector-icons": "^6.3.0", "react-native-web": "^0.7.3", "react-native-webview": "^8.0.5", "react-native-wheel-pick": "^1.0.9", "react-navigation": "^3.7.1", "react-redux": "^5.0.7", "react-redux-firebase": "^2.2.6", "redux": "^4.0.1", "redux-devtools-extension": "^2.13.8", "redux-firestore": "^0.7.2", "redux-logger": "^3.0.6", "redux-persist": "^5.10.0", "redux-thunk": "^2.3.0", "tipsi-stripe": "8.0.0-beta.9" }, "devDependencies": { "@babel/core": "^7.6.2", "@babel/runtime": "^7.6.2", "@react-native-community/cli": "^3.0.4", "@react-native-community/eslint-config": "^0.0.5", "babel-jest": "^24.9.0", "eslint": "^6.7.2", "jest": "^24.9.0", "metro-react-native-babel-preset": "^0.56.0", "react-test-renderer": "16.9.0" }, "jest": { "preset": "react-native" } }
# N/A
#### `firebase.json` for react-native-firebase v6:
{
"hosting": {
"public": "./",
"ignore": [
"firebase.json",
"database-rules.json",
"storage.rules",
"functions"
],
"headers": [
{
"source": "**/*.@(js|html)",
"headers": [
{
"key": "Cache-Control",
"value": "max-age=0"
}
]
}
],
"rewrites": [
{
"source": "**",
"destination": "/index.html"
},
{
"source": "/**",
"dynamicLinks": true
}
]
},
"firestore": {
"rules": "firestore.rules",
"indexes": "firestore.indexes.json"
},
"functions": {
"predeploy": [
"npm --prefix \"$RESOURCE_DIR\" run lint"
]
}
}
# N/A
### iOS
#### `ios/Podfile`: - [ ] I'm not using Pods - [x] I'm using Pods and my Podfile looks like: Pod file was generated successfully from node_modules. Updated from version 6.2, cleared cache and cleaned build files in Xcode. however error persists. # Uncomment the next line to define a global platform for your project. platform :ios, '9.0' require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules' target 'myAppName' do # Uncomment the next line if you're using Swift or would like to use dynamic frameworks # use_frameworks! pod 'FBLazyVector', :path => "../node_modules/react-native/Libraries/FBLazyVector" pod 'FBReactNativeSpec', :path => "../node_modules/react-native/Libraries/FBReactNativeSpec" pod 'RCTRequired', :path => "../node_modules/react-native/Libraries/RCTRequired" pod 'RCTTypeSafety', :path => "../node_modules/react-native/Libraries/TypeSafety" pod 'React', :path => '../node_modules/react-native/' pod 'React-Core', :path => '../node_modules/react-native/' pod 'React-CoreModules', :path => '../node_modules/react-native/React/CoreModules' pod 'React-Core/DevSupport', :path => '../node_modules/react-native/' pod 'React-RCTActionSheet', :path => '../node_modules/react-native/Libraries/ActionSheetIOS' pod 'React-RCTAnimation', :path => '../node_modules/react-native/Libraries/NativeAnimation' pod 'React-RCTBlob', :path => '../node_modules/react-native/Libraries/Blob' pod 'React-RCTImage', :path => '../node_modules/react-native/Libraries/Image' pod 'React-RCTLinking', :path => '../node_modules/react-native/Libraries/LinkingIOS' pod 'React-RCTNetwork', :path => '../node_modules/react-native/Libraries/Network' pod 'React-RCTSettings', :path => '../node_modules/react-native/Libraries/Settings' pod 'React-RCTText', :path => '../node_modules/react-native/Libraries/Text' pod 'React-RCTVibration', :path => '../node_modules/react-native/Libraries/Vibration' pod 'React-Core/RCTWebSocket', :path => '../node_modules/react-native/' pod 'React-cxxreact', :path => '../node_modules/react-native/ReactCommon/cxxreact' pod 'React-jsi', :path => '../node_modules/react-native/ReactCommon/jsi' pod 'React-jsiexecutor', :path => '../node_modules/react-native/ReactCommon/jsiexecutor' pod 'React-jsinspector', :path => '../node_modules/react-native/ReactCommon/jsinspector' pod 'ReactCommon/jscallinvoker', :path => "../node_modules/react-native/ReactCommon" pod 'ReactCommon/turbomodule/core', :path => "../node_modules/react-native/ReactCommon" pod 'Yoga', :path => '../node_modules/react-native/ReactCommon/yoga' pod 'DoubleConversion', :podspec => '../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec' pod 'glog', :podspec => '../node_modules/react-native/third-party-podspecs/glog.podspec' pod 'Folly', :podspec => '../node_modules/react-native/third-party-podspecs/Folly.podspec' target 'myAppNameTests' do inherit! :search_paths # Pods for testing end use_native_modules! end # removed as not generating tvOS version of app #target 'RnDiffApp-tvOS' do # # Pods for RnDiffApp-tvOS # target 'RnDiffApp-tvOSTests' do # inherit! :search_paths # # Pods for testing # end
# N/A
#### `AppDelegate.m`:
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
#import "AppDelegate.h"
@import Firebase;
#import "ReactNativeConfig.h"
#import // N/A
Click To Expand
#### Have you converted to AndroidX? - [ ] my application is an AndroidX application? - [ ] I am using `android/gradle.settings` `jetifier=true` for Android compatibility? - [ ] I am using the NPM package `jetifier` for react-native compatibility? #### `android/build.gradle`:
// N/A
#### `android/app/build.gradle`:
// N/A
#### `android/settings.gradle`:
// N/A
#### `MainApplication.java`:
// N/A
#### `AndroidManifest.xml`:
<!-- N/A -->
Click To Expand
**`react-native info` output:** System: OS: macOS Mojave 10.14.6 CPU: (4) x64 Intel(R) Core(TM) i7-4650U CPU @ 1.70GHz Memory: 17.67 MB / 8.00 GB Shell: 3.2.57 - /bin/bash Binaries: Node: 12.13.1 - /usr/local/bin/node Yarn: 1.5.1 - /usr/local/bin/yarn npm: 6.12.1 - /usr/local/bin/npm Watchman: 4.9.0 - /usr/local/bin/watchman SDKs: iOS SDK: Platforms: iOS 13.2, DriverKit 19.0, macOS 10.15, tvOS 13.2, watchOS 6.1 IDEs: Xcode: 11.2.1/11B500 - /usr/bin/xcodebuild npmPackages: @react-native-community/cli: ^3.0.4 => 3.0.4 react: 16.9.0 => 16.9.0 react-native: 0.61.5 => 0.61.5 npmGlobalPackages: create-react-native-app: 1.0.0 react-native-git-upgrade: 0.2.7
OUTPUT GOES HERE
- **Platform that you're experiencing the issue on**:
- [] iOS
- [ ] Android
- [x] **iOS** but have not tested behavior on Android
- [ ] **Android** but have not tested behavior on iOS
- [ ] Both
- **`react-native-firebase` version you're using that has this issue:**
- 6.3.4 and 6.2
- **`Firebase` module(s) you're using that has the issue:**
- @react-native-firebase/dynamic-links
- **Are you using `TypeScript`?**
- N
Think react-native-firebase is great? Please consider supporting all of the project maintainers and contributors by donating via our Open Collective where all contributors can submit expenses. [Learn More]
React Native Firebase and Invertase on Twitter for updates on the library.Thanks for the report @danneu2s1fa
I see the issue here, the native 'promise' is getting resolved twice, this is due to a missing return; https://github.com/invertase/react-native-firebase/blob/master/packages/dynamic-links/ios/RNFBDynamicLinks/RNFBDynamicLinksModule.m#L69
Easy fix, we'll look into a PR
Hi Salakar / Russell,
Thanks for your reply and the quick response with the code change.
Can you point me to instructions to efficiently download this change to my local copy without impacting my ability to update the library going forward?
Can I get notified when this change in 'master' is merged with a release version?
Cheers!
@danneu2s1fa you want to install patch-package according to it's instructions: https://github.com/ds300/patch-package
Then you want to make the identical change to the commit https://github.com/invertase/react-native-firebase/pull/3318/files#diff-157a394113a3b9817cfd7e0e1de96469R70 directly in the file in node_modules
Then you follow the patch-package directions to generate a patch for this version with your change
That's it - it will be automatically applied now any time another developer or CI or anything checks out your project and runs yarn or npm install
And when the next version comes out, if the patch is already included patch-package will give you a big obvious message with advice that you can remove the patch
It's exactly what you need to incorporate master-only (or even local only-you-need-it) changes before a release
@mikehardy thanks for the instructions. Creating the patch worked.
@Salakar: I made the change to my local copy, however I get an error on building in XCode. (see below) Any insight / fix to why this fails?
Change made here: /node_modules/@react-native-firebase/dynamic-links/ios/RNFBDynamicLinks/RNFBDynamicLinksModule.m
Change:
if (!linkComponents || !linkComponents.url) {
[RNFBSharedUtils rejectPromiseWithUserInfo:reject userInfo:(NSMutableDictionary *) @{
@"code": @"build-failed",
@"message": @"Failed to build dynamic link for unknown reason",
}];
return
}
Error in XCode:
Showing All Messages
/node_modules/@react-native-firebase/dynamic-links/ios/RNFBDynamicLinks/RNFBDynamicLinksModule.m:71:3: error: expected expression
}
^
1 error generated.
I think it's missing the ; ?
@mikehardy - The missing ; fix the issue. Thanks for catching this, and for taking your time to respond. Cheers! - D.
@mikehardy @Salakar @russellwheatley - The code above now runs throwing the error below and returns 'undefined' for the link value.
This javascript code above previously returned a functional link. Is there anything else that you would suggest checking? Thanks again in advance.
The error I see is as follows:
namespace:"dynamicLinks"
nativeErrorCode:null
nativeErrorMessage:null
stack:"NativeFirebaseError: [dynamicLinks/build-failed] Failed to build dynamic link for unknown reason
at FirebaseLinksModule.buildLink (/.vscode/.react/index.bundle:134588:28)
at sendButton._handleRNMailer$ (http://172.168.1.10:8081/app/lib/sendButton.bundle?platform=ios&dev=true&minify=false&modulesOnly=true&runModule=false&shallow=true:407:79)
at tryCatch (/.vscode/.react/index.bundle:30648:19)
at Generator.invoke [as _invoke] (/.vscode/.react/index.bundle:30823:24)
at Generator.prototype.
at tryCatch (/.vscode/.react/index.bundle:30648:19)
at invoke (/.vscode/.react/index.bundle:30724:22)
at /.vscode/.react/index.bundle:30754:13
at tryCallTwo (/.vscode/.react/i...
userInfo:Object {message: "Failed to build dynamic link for unknown reason", code: "build-failed"}
__proto__:Wrapper {constructor: , getStackWithMessage: }
Most helpful comment
@mikehardy - The missing ; fix the issue. Thanks for catching this, and for taking your time to respond. Cheers! - D.