Closed canpoyrazoglu closed 1 year ago
Merhaba, Can! We haven't reviewed our error decoding strategy yet, so it can result in unknown errors occasionally.
Is Argument 'product' was not passed to a native module.
a string that comes with unknown error?
It can happen not only when argument was not passed, but also when it failed to decode after successful JSON encoding (that should not happen)
May I ask you to launch your app with 'verbose'
logLevel and check what is being passed to a native layer? You should just perform this buggy flow.
What I'm most curious about is debug log with label Calling bridge function... { methodName: "make_purchase", args: {...}
. This is the log that shows the payload that is being passed to a native layer.
I bet that product, that is being passed in this args
will lack some of required keys. Feel free to share it, so we can investigate together what is missing there. I don't really think, that there are any sensitive data there, but if you decide otherwise you can also tell us and we will contact you to a more private space.
Is this a totally new product? Was there recently some mutations regarding this product?
@canpoyrazoglu mentioning in case you don't get notified otherwise
Hi @divanc :)
Here is another screenshot from my debugging environment when the breakpoint at return new BridgeError('unknown', 'Failed to deserialize a native error message', 'Check the logs for more details');
in bridgeError.js:50
is hit:
I've started react-native
with --verbose
flag though I'm not seeing any verbose logs. All I'm seeing is the logs/errors that I have already been seeing without the flag. (perhaps https://github.com/react-native-community/cli/pull/1946 is not upstream yet?)
However, if it helps, I've set up a native breakpoint at RNAdapty.swift:315
at handleMakePurchase
and it gets hit to return ctx.argNotFound(name: Const.PRODUCT)
, here is a screenshot:
I'll also send the product data if still needed if I'm cleared by my team members, or through a private channel shortly.
Hope the current data helps in meantime.
Oh no, to output verbose logs, you need to add a property to activate call like this:
adapty.activate('PUBLIC_SDK_KEY', { logLevel: 'verbose' });
You can refer to second example here: https://docs.adapty.io/docs/react-native-configuring
It would provide huge amount of data to your RN development server. There you will be able to find what we are looking for
@canpoyrazoglu
It is also productStr on line 315 in your Xcode screenshot if you prefer to breakpoint
Okay, I've initialized with verbose logging. Here is the error message at JS side when I try to make the purchase, along with additional logs/errors just after it, to the relevant extent (app name redacted in public):
INFO [Adapty JS vUNKNOWN] — info: : --> Calling native SDK
args="{}"
DEBUG [Adapty JS vUNKNOWN] — verbose: bridgeCall: Calling native method.
methodName="make_purchase"
args="{}"
LOG log btn_paywall_payment undefined
DEBUG [Adapty JS vUNKNOWN] — verbose: bridgeCall: Native method returned an error.
methodName="make_purchase"
args="{}"
error="{\n \"code\": \"adapty_native_error\",\n \"message\": \"Argument 'product' was not passed to a native module.\",\n \"domain\": \"RCTErrorDomain\",\n \"userInfo\": null,\n \"nativeStackIOS\": [\n \"0 myapp 0x00000001046fdf40 RCTJSErrorFromCodeMessageAndNSError + 112\",\n \"1 myapp 0x000000010469b854 __41-[RCTModuleMethod processMethodSignature]_block_invoke_2.73 + 152\",\n \"2 myapp 0x0000000104469db8 $sSo8NSStringCSgACSo7NSErrorCSgIeyByyy_SSSgAGs5Error_pSgIegggg_TR + 380\",\n \"3 myapp 0x0000000104aedddc $s19react_native_adapty13AdaptyContextV6reject7dataStrySS_tF + 152\",\n \"4 myapp 0x0000000104aedfe4 $s19react_native_adapty13AdaptyContextV11argNotFound4nameySS_tF + 300\",\n \"5 myapp 0x0000000104ae7f7c $s19react_native_adapty8RNAdaptyC18handleMakePurchase33_E2C7934C16948D97B8243DEBDB1FCA6ELLyyAA13AdaptyContextVF + 1104\",\n \"6 myapp 0x0000000104ae2910 $s19react_native_adapty8RNAdaptyC6handle_4args8resolver8rejecterySo8NSStringC_So12NSDictionaryCyypSgcySSSg_AMs5Error_pSgtctF + 512\",\n \"7 myapp 0x0000000104ae2b00 $s19react_native_adapty8RNAdaptyC6handle_4args8resolver8rejecterySo8NSStringC_So12NSDictionaryCyypSgcySSSg_AMs5Error_pSgtctFTo + 220\",\n \"8 CoreFoundation 0x00000001081006c0 __invoking___ + 144\",\n \"9 CoreFoundation 0x00000001080fda44 -[NSInvocation invoke] + 276\",\n \"10 CoreFoundation 0x00000001080fdcdc -[NSInvocation invokeWithTarget:] + 60\",\n \"11 myapp 0x000000010469ce2c -[RCTModuleMethod invokeWithBridge:module:arguments:] + 1808\",\n \"12 myapp 0x00000001046a0d2c _ZN8facebook5reactL11invokeInnerEP9RCTBridgeP13RCTModuleDatajRKN5folly7dynamicEiN12_GLOBAL__N_117SchedulingContextE + 1596\",\n \"13 myapp 0x00000001046a0524 _ZZN8facebook5react15RCTNativeModule6invokeEjON5folly7dynamicEiENK3$_0clEv + 128\",\n \"14 myapp 0x00000001046a0498 ___ZN8facebook5react15RCTNativeModule6invokeEjON5folly7dynamicEi_block_invoke + 28\",\n \"15 libdispatch.dylib 0x000000011070dee4 _dispatch_call_block_and_release + 24\",\n \"16 libdispatch.dylib 0x000000011070f708 _dispatch_client_callout + 16\",\n \"17 libdispatch.dylib 0x000000011071777c _dispatch_lane_serial_drain + 776\",\n \"18 libdispatch.dylib 0x00000001107183dc _dispatch_lane_invoke + 392\",\n \"19 libdispatch.dylib 0x0000000110724608 _dispatch_workloop_worker_thread + 768\",\n \"20 libsystem_pthread.dylib 0x00000001b1834878 _pthread_wqthread + 284\",\n \"21 libsystem_pthread.dylib 0x00000001b183363c start_wqthread + 8\"\n ]\n}"
DEBUG [Adapty JS vUNKNOWN] — verbose: BridgeError.nativeErr: Creating new BridgeError from native error...
args="{\n \"code\": \"adapty_native_error\",\n \"message\": \"Argument 'product' was not passed to a native module.\",\n \"domain\": \"RCTErrorDomain\",\n \"userInfo\": null,\n \"nativeStackIOS\": [\n \"0 myapp 0x00000001046fdf40 RCTJSErrorFromCodeMessageAndNSError + 112\",\n \"1 myapp 0x000000010469b854 __41-[RCTModuleMethod processMethodSignature]_block_invoke_2.73 + 152\",\n \"2 myapp 0x0000000104469db8 $sSo8NSStringCSgACSo7NSErrorCSgIeyByyy_SSSgAGs5Error_pSgIegggg_TR + 380\",\n \"3 myapp 0x0000000104aedddc $s19react_native_adapty13AdaptyContextV6reject7dataStrySS_tF + 152\",\n \"4 myapp 0x0000000104aedfe4 $s19react_native_adapty13AdaptyContextV11argNotFound4nameySS_tF + 300\",\n \"5 myapp 0x0000000104ae7f7c $s19react_native_adapty8RNAdaptyC18handleMakePurchase33_E2C7934C16948D97B8243DEBDB1FCA6ELLyyAA13AdaptyContextVF + 1104\",\n \"6 myapp 0x0000000104ae2910 $s19react_native_adapty8RNAdaptyC6handle_4args8resolver8rejecterySo8NSStringC_So12NSDictionaryCyypSgcySSSg_AMs5Error_pSgtctF + 512\",\n \"7 myapp 0x0000000104ae2b00 $s19react_native_adapty8RNAdaptyC6handle_4args8resolver8rejecterySo8NSStringC_So12NSDictionaryCyypSgcySSSg_AMs5Error_pSgtctFTo + 220\",\n \"8 CoreFoundation 0x00000001081006c0 __invoking___ + 144\",\n \"9 CoreFoundation 0x00000001080fda44 -[NSInvocation invoke] + 276\",\n \"10 CoreFoundation 0x00000001080fdcdc -[NSInvocation invokeWithTarget:] + 60\",\n \"11 myapp 0x000000010469ce2c -[RCTModuleMethod invokeWithBridge:module:arguments:] + 1808\",\n \"12 myapp 0x00000001046a0d2c _ZN8facebook5reactL11invokeInnerEP9RCTBridgeP13RCTModuleDatajRKN5folly7dynamicEiN12_GLOBAL__N_117SchedulingContextE + 1596\",\n \"13 myapp 0x00000001046a0524 _ZZN8facebook5react15RCTNativeModule6invokeEjON5folly7dynamicEiENK3$_0clEv + 128\",\n \"14 myapp 0x00000001046a0498 ___ZN8facebook5react15RCTNativeModule6invokeEjON5folly7dynamicEi_block_invoke + 28\",\n \"15 libdispatch.dylib 0x000000011070dee4 _dispatch_call_block_and_release + 24\",\n \"16 libdispatch.dylib 0x000000011070f708 _dispatch_client_callout + 16\",\n \"17 libdispatch.dylib 0x000000011071777c _dispatch_lane_serial_drain + 776\",\n \"18 libdispatch.dylib 0x00000001107183dc _dispatch_lane_invoke + 392\",\n \"19 libdispatch.dylib 0x0000000110724608 _dispatch_workloop_worker_thread + 768\",\n \"20 libsystem_pthread.dylib 0x00000001b1834878 _pthread_wqthread + 284\",\n \"21 libsystem_pthread.dylib 0x00000001b183363c start_wqthread + 8\"\n ]\n}"
ERROR [Adapty JS vUNKNOWN] — ERROR: BridgeError.nativeErr: Failed to deserialize a native error message
args="{\n \"code\": \"adapty_native_error\",\n \"message\": \"Argument 'product' was not passed to a native module.\",\n \"domain\": \"RCTErrorDomain\",\n \"userInfo\": null,\n \"nativeStackIOS\": [\n \"0 myapp 0x00000001046fdf40 RCTJSErrorFromCodeMessageAndNSError + 112\",\n \"1 myapp 0x000000010469b854 __41-[RCTModuleMethod processMethodSignature]_block_invoke_2.73 + 152\",\n \"2 myapp 0x0000000104469db8 $sSo8NSStringCSgACSo7NSErrorCSgIeyByyy_SSSgAGs5Error_pSgIegggg_TR + 380\",\n \"3 myapp 0x0000000104aedddc $s19react_native_adapty13AdaptyContextV6reject7dataStrySS_tF + 152\",\n \"4 myapp 0x0000000104aedfe4 $s19react_native_adapty13AdaptyContextV11argNotFound4nameySS_tF + 300\",\n \"5 myapp 0x0000000104ae7f7c $s19react_native_adapty8RNAdaptyC18handleMakePurchase33_E2C7934C16948D97B8243DEBDB1FCA6ELLyyAA13AdaptyContextVF + 1104\",\n \"6 myapp 0x0000000104ae2910 $s19react_native_adapty8RNAdaptyC6handle_4args8resolver8rejecterySo8NSStringC_So12NSDictionaryCyypSgcySSSg_AMs5Error_pSgtctF + 512\",\n \"7 myapp 0x0000000104ae2b00 $s19react_native_adapty8RNAdaptyC6handle_4args8resolver8rejecterySo8NSStringC_So12NSDictionaryCyypSgcySSSg_AMs5Error_pSgtctFTo + 220\",\n \"8 CoreFoundation 0x00000001081006c0 __invoking___ + 144\",\n \"9 CoreFoundation 0x00000001080fda44 -[NSInvocation invoke] + 276\",\n \"10 CoreFoundation 0x00000001080fdcdc -[NSInvocation invokeWithTarget:] + 60\",\n \"11 myapp 0x000000010469ce2c -[RCTModuleMethod invokeWithBridge:module:arguments:] + 1808\",\n \"12 myapp 0x00000001046a0d2c _ZN8facebook5reactL11invokeInnerEP9RCTBridgeP13RCTModuleDatajRKN5folly7dynamicEiN12_GLOBAL__N_117SchedulingContextE + 1596\",\n \"13 myapp 0x00000001046a0524 _ZZN8facebook5react15RCTNativeModule6invokeEjON5folly7dynamicEiENK3$_0clEv + 128\",\n \"14 myapp 0x00000001046a0498 ___ZN8facebook5react15RCTNativeModule6invokeEjON5folly7dynamicEi_block_invoke + 28\",\n \"15 libdispatch.dylib 0x000000011070dee4 _dispatch_call_block_and_release + 24\",\n \"16 libdispatch.dylib 0x000000011070f708 _dispatch_client_callout + 16\",\n \"17 libdispatch.dylib 0x000000011071777c _dispatch_lane_serial_drain + 776\",\n \"18 libdispatch.dylib 0x00000001107183dc _dispatch_lane_invoke + 392\",\n \"19 libdispatch.dylib 0x0000000110724608 _dispatch_workloop_worker_thread + 768\",\n \"20 libsystem_pthread.dylib 0x00000001b1834878 _pthread_wqthread + 284\",\n \"21 libsystem_pthread.dylib 0x00000001b183363c start_wqthread + 8\"\n ]\n}"
DEBUG [Adapty JS vUNKNOWN] — verbose: BridgeError: Raised new BridgeError
adapty_code="unknown"
message="Failed to deserialize a native error message"
detail="Check the logs for more details"
ERROR [Adapty JS vUNKNOWN] — ERROR: : <-- Native SDK replied with error
error="#0 (unknown): Failed to deserialize a native error message"
nativeError="{\n \"code\": \"adapty_native_error\",\n \"message\": \"Argument 'product' was not passed to a native module.\",\n \"domain\": \"RCTErrorDomain\",\n \"userInfo\": null,\n \"nativeStackIOS\": [\n \"0 myapp 0x00000001046fdf40 RCTJSErrorFromCodeMessageAndNSError + 112\",\n \"1 myapp 0x000000010469b854 __41-[RCTModuleMethod processMethodSignature]_block_invoke_2.73 + 152\",\n \"2 myapp 0x0000000104469db8 $sSo8NSStringCSgACSo7NSErrorCSgIeyByyy_SSSgAGs5Error_pSgIegggg_TR + 380\",\n \"3 myapp 0x0000000104aedddc $s19react_native_adapty13AdaptyContextV6reject7dataStrySS_tF + 152\",\n \"4 myapp 0x0000000104aedfe4 $s19react_native_adapty13AdaptyContextV11argNotFound4nameySS_tF + 300\",\n \"5 myapp 0x0000000104ae7f7c $s19react_native_adapty8RNAdaptyC18handleMakePurchase33_E2C7934C16948D97B8243DEBDB1FCA6ELLyyAA13AdaptyContextVF + 1104\",\n \"6 myapp 0x0000000104ae2910 $s19react_native_adapty8RNAdaptyC6handle_4args8resolver8rejecterySo8NSStringC_So12NSDictionaryCyypSgcySSSg_AMs5Error_pSgtctF + 512\",\n \"7 myapp 0x0000000104ae2b00 $s19react_native_adapty8RNAdaptyC6handle_4args8resolver8rejecterySo8NSStringC_So12NSDictionaryCyypSgcySSSg_AMs5Error_pSgtctFTo + 220\",\n \"8 CoreFoundation 0x00000001081006c0 __invoking___ + 144\",\n \"9 CoreFoundation 0x00000001080fda44 -[NSInvocation invoke] + 276\",\n \"10 CoreFoundation 0x00000001080fdcdc -[NSInvocation invokeWithTarget:] + 60\",\n \"11 myapp 0x000000010469ce2c -[RCTModuleMethod invokeWithBridge:module:arguments:] + 1808\",\n \"12 myapp 0x00000001046a0d2c _ZN8facebook5reactL11invokeInnerEP9RCTBridgeP13RCTModuleDatajRKN5folly7dynamicEiN12_GLOBAL__N_117SchedulingContextE + 1596\",\n \"13 myapp 0x00000001046a0524 _ZZN8facebook5react15RCTNativeModule6invokeEjON5folly7dynamicEiENK3$_0clEv + 128\",\n \"14 myapp 0x00000001046a0498 ___ZN8facebook5react15RCTNativeModule6invokeEjON5folly7dynamicEi_block_invoke + 28\",\n \"15 libdispatch.dylib 0x000000011070dee4 _dispatch_call_block_and_release + 24\",\n \"16 libdispatch.dylib 0x000000011070f708 _dispatch_client_callout + 16\",\n \"17 libdispatch.dylib 0x000000011071777c _dispatch_lane_serial_drain + 776\",\n \"18 libdispatch.dylib 0x00000001107183dc _dispatch_lane_invoke + 392\",\n \"19 libdispatch.dylib 0x0000000110724608 _dispatch_workloop_worker_thread + 768\",\n \"20 libsystem_pthread.dylib 0x00000001b1834878 _pthread_wqthread + 284\",\n \"21 libsystem_pthread.dylib 0x00000001b183363c start_wqthread + 8\"\n ]\n}"
ERROR Unable to purchase [Error: #0 (unknown): Failed to deserialize a native error message]
I doubt that args should be empty, let me jump back to your version and check today
Yeah, that seems to be the problem at native side. But I don't get why it's empty in the first place, as I'm passing a valid object to the function at JS side, where it works perfectly with another product nevertheless.
Okay after a long dive here was the result:
I was caching Adapty paywall objects in my persisted Redux store as fetching them was sometimes slow and I needed some of them them on app start early on. When I was reopening my app, I had them ready, but in case something changed (e.g. price adjusted on Adapty) I was force-reloading some of the most-early-on used paywalls from Adapty anyway:
It seemed to be best of both worlds, I always had data, and I also refreshed the most common used ones in the background when my app opened.
However that turned out to be problematic: Adapty also has a caching mechanism within itself that is not persisted, but cached throughout the session, and it always sends the object (product+variation) after reading it with that key from the cache. When I was trying to use one of the force-refreshed paywalls (which were reloaded on app start) it was hitting the cache and presenting the paywall with the latest Adapty-loaded paywall.
When I was trying to feed a cached (from a previous app session) paywall which wasn't force-reloaded on app start, it looked like a perfect normal object from outside, yet as Adapty was caching it session-wise and that product wasn't loaded in the current session, Adapty's internal cache was missing the entry, returning undefined
, and causing all sorts of errors downstream, understandably, as it doesn't seem to be a supported scenario.
I've changed my code to load all the other paywalls that might be needed and the problem went away, as Adapty now caches them on app start after the first load, which correctly gets cached and is hit by Adapty's internal JS-side cache correctly.
TL;DR: Don't persist Adapty products on Redux on app close. I was using a redux-persisted object from a previous app session which didn't play well with Adapty's session-level cache. Fixed by discarding that object and loading that fresh from Adapty on app start.
I had a talk with native developers, it is possible to freeze products, although they would look a little different, I'll try to implement this possibility in v2.5.0
Description
I'm trying to make a purchase by calling
await adapty.makePurchase(product);
whereproduct
is:(details redacted for privacy)
I'm getting the "Failed to deserialize a native error message" message again. I've also raised another issue in the past (https://github.com/adaptyteam/AdaptySDK-React-Native/issues/76) which was being raised the same way but the underlying error is different here (it was me passing an object instead of a string, which is not the case here).
I'm getting "Argument 'product' was not passed to a native module." but I'm calling
adapty.makePurchase
with aproduct
object as seen above, which is a clear and validproduct
object.More weirdly, I have another paywall which uses the exact same code path just with a different
product
(but has the same shape/fields), it works perfectly.What might be going on?
Version
v2.4.2
What platforms are you seeing the problem on?
iOS
System info