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

Malformed calls from JS: field sizes are different #2744

Closed
5 of 11 tasks
TheTreek opened this issue Jan 12, 2023 · 34 comments · Fixed by #2852
Closed
5 of 11 tasks

Malformed calls from JS: field sizes are different #2744

TheTreek opened this issue Jan 12, 2023 · 34 comments · Fixed by #2852

Comments

@TheTreek
Copy link

OS:

  • Windows
  • MacOS
  • Linux

Platform:

  • iOS
  • Android

SDK:

  • @sentry/react-native (>= 1.0.0)
  • react-native-sentry (<= 0.43.2)

SDK version: 4.12.0

react-native version: 0.64.4

Are you using Expo?

  • Yes
  • No

Are you using sentry.io or on-premise?

  • sentry.io (SaaS)
  • on-premise

If you are using sentry.io, please post a link to your issue so we can take a look:

[Link to issue]

Configuration:

(@sentry/react-native)

Sentry.init({
  dsn: 'https://[email protected]/...'
  tracesSampleRate: 0.25,
  captureFailedRequestsEnabled: true,
  debug: true,
  enableNdkScopeSync: true,
});

I have following issue:

When calling Sentry.captureMessage("Custom message", 'error') on iOS this error is logged:

 ERROR  Sentry Logger [error]: Error while sending event: [Error: Exception in HostFunction: Malformed calls from JS: field sizes are different.

[[42,81],[7,0],[[146,100,1673548149834,false]],379]]

I was able to determine this is happening @sentry/react-native calls RNSentry.captureEnvelope() (node_modules/@sentry/react-native/dist/js/wrapper.js:72). Looks like a react-native bridging issue.

Steps to reproduce:

  • Call Sentry.captureMessage("Custom message here", 'error') on iOS
  • See that it fails to capture the message.

Actual result:

ERROR  Sentry Logger [error]: Error while sending event: [Error: Exception in HostFunction: Malformed calls from JS: field sizes are different.

[[42,81],[7,0],[[142,100,1673548954018,false]],354]]

Expected result:

[Expected result]

@krystofwoldrich
Copy link
Member

Thanks for the message.

Here is another issue with the same error and more details about it on Android.

@krystofwoldrich krystofwoldrich changed the title Issue calling Sentry.captureMessage() on iOS Malformed calls from JS: field sizes are different Jan 16, 2023
@krystofwoldrich
Copy link
Member

@TheTreek How did you track down the RNSentry.captureEnvelope()? Did you use this?

Could you try to call this code to see what is moduleId 81 and methodId 0?

if (global.__fbBatchedBridge) {
  const origMessageQueue = global.__fbBatchedBridge;
  const modules = origMessageQueue._remoteModuleTable;
  const methods = origMessageQueue._remoteMethodTable;
  global.findModuleByModuleAndMethodIds = (moduleId, methodId) => {
    console.log(`The problematic line code is in: ${modules?.[moduleId]}.${methods?.[moduleId]?.[methodId]}`)
  }
}

global.findModuleByModuleAndMethodIds(81, 0);

@krystofwoldrich krystofwoldrich moved this from Needs Discussion to Needs More Information in Mobile & Cross Platform SDK Jan 26, 2023
@krystofwoldrich
Copy link
Member

@Mkolakoglu Sadly I wasn't able to reproduce the issue after installing the react-redux and redux-logger.

Based on your logs the moduleId.methodId 13.0 and 41.0 could be the issue.

Can you run the following code to decode the modules and method names?

if (global.__fbBatchedBridge) {
  const origMessageQueue = global.__fbBatchedBridge;
  const modules = origMessageQueue._remoteModuleTable;
  const methods = origMessageQueue._remoteMethodTable;
  global.findModuleByModuleAndMethodIds = (moduleId, methodId) => {
    console.log(`The problematic line code is in: ${modules?.[moduleId]}.${methods?.[moduleId]?.[methodId]}`)
  }
}

global.findModuleByModuleAndMethodIds(13, 0);
global.findModuleByModuleAndMethodIds(41, 0);

@krystofwoldrich
Copy link
Member

@JimTeva Based on your logs the module and method ids that could cause the problem are 59 and 0. Could you also try the code above and send us the module name and method name?

@TheTreek
Copy link
Author

@TheTreek How did you track down the RNSentry.captureEnvelope()? Did you use this?

I tracked it down by putting console logs at all the points leading towards RNSentry.captureEnvelope() and saw that there were no logs after RNSentry.captureEnvelope() (on iOS)

Can you run the following code to decode the modules and method names?

I put that code in App.js right after Sentry.init() and got: The problematic line code is in: Timing.createTimer

@JimTeva
Copy link

JimTeva commented Jan 27, 2023

@krystofwoldrich i've tried running the code after Sentry.init but nothing logged.
Tried also at the end of ComponentDidMount in my main component but nothing logged.
Where exactly do we run the code above?

@krystofwoldrich
Copy link
Member

@JimTeva Both places you mentioned are okay, are you trying in a dev build? Can you check if global.__fbBatchedBridge exists?

@Aryk
Copy link

Aryk commented Jan 28, 2023

@krystofwoldrich I think I'm getting this same problem.

I ran the same code and got the same @TheTreek in RNSentry.captureEnvelope

I'm using Expo with

"@sentry/react-native": "^4.9.0",
"sentry-expo": "~6.0.0"

That's what they recommended for SDK 47


Quick Update: It seems like if I sleep the thread:

      Sentry.Native.captureMessage("def")
      await sleep(200)
      Sentry.Native.captureMessage("foo")

The first will get sent and the second not. This tells me there is something happening in parallel on bootup that's causing Sentry.Native functions to get screwed up. Maybe another library that's overwriting the functions or something?

FWIW, I downgraded to 4.2.2 (which is the next version down with sentry-expo 5.0.3 back from last October and have no problems...so will stick with that until this is resolved.

@JimTeva
Copy link

JimTeva commented Jan 28, 2023

@krystofwoldrich I finally got your debug code above to work and the result is the same as @TheTreek:

The problematic line code is in: Timing.createTimer

@krystofwoldrich
Copy link
Member

@Aryk Where do you call the mentioned code? On a button click? Right after Sentry.init?

@krystofwoldrich
Copy link
Member

@JimTeva and @TheTreek sadly the module and method information is less helpful than I hoped for.

Would you be able to create a minimal reproducible example?

@Aryk
Copy link

Aryk commented Jan 30, 2023

@krystofwoldrich Sentry.init is run on the main thread before everything.

This was called in the top level component of the app in a useEffect function, so it was happening on app bootup. I'm 90% sure that it's some library loading in tandem that is conflicting with it as my example suggests.

I rolled back my version of Sentry to 4.2.2 and zero problems so sticking to that. I'm not sure what new stuff got released but don't need any fancy features...just need to report errors to Sentry lol.

@krystofwoldrich
Copy link
Member

@Aryk Would you be able to create a minimal reproducible example that we could debug the issue on?

@Aryk
Copy link

Aryk commented Jan 31, 2023

@TheTreek and @JimTeva can you guys try running Sentry.captureMessage("test") right after you can Sentry.init and see if that works. That would confirm the thesis that it works at some point and then stops working.

These next few weeks we're crazy swamped with getting a new release out so can't do it soon, but i bet you that @TheTreek and @JimTeva will have the same behavior as what I'm seeing.

@github-actions
Copy link
Contributor

This issue has gone three weeks without activity. In another week, I will close it.

But! If you comment or otherwise update it, I will reset the clock, and if you label it Status: Backlog or Status: In Progress, I will leave it alone ... forever!


"A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀

@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 Sep 9, 2023
@krystofwoldrich
Copy link
Member

@axoTheLotl Thank you for the message, a fix for the issue with the transactions is described https://docs.expo.dev/guides/using-sentry/#troubleshooting

@guiccbr
Copy link

guiccbr commented Oct 17, 2023

This started to happen to me as well after upgrading expo + react-native:

expo: 48.0.18
react-native: 0.71.13
@sentry/react-native: 4.15.2

The issue happens on iOS (haven't checked on Android yet). And it affects only development builds. The problem doesn't occur in production, neither when I use expo go.

Setting debug: false/true doesn't seem to be making any difference to me.

I had to disable sentry on development by setting enableInExpoDevelopment: false to be able to run my app.

Is there any better workaround for this atm?

@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 Oct 17, 2023
@krystofwoldrich
Copy link
Member

@guiccbr Thank you for the info, sadly, there is no workaround besides running Release at the moment.

@mogelbrod
Copy link

mogelbrod commented Nov 1, 2023

I'm trying to upgrade @sentry/react-native from v4.15 to 5.12.0 and this issue is making it a lot harder to debug why error reporting suddenly stopped working 😞 Errors don't appear to be reported in simulator builds, no matter where I put them or if debug is enabled or not. With debug enabled I get the same error as has been described above:

Sentry Logger [error]: Error while sending event: [Error: Exception in HostFunction: Malformed calls from JS: field sizes are different.
[[47,83],[9,0],[[273,100,1698835399092,false]],1613]]

@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 Nov 1, 2023
@krystofwoldrich
Copy link
Member

@mogelbrod Thank you for the message, have you tried to build a release version of your app?

@dnl-jst
Copy link

dnl-jst commented Nov 8, 2023

I'm experiencing the same issue on [email protected] and @sentry/[email protected]. The first tracing result is submitted, but after that every tracing submission leads to:

Sentry Logger [error]: Error while sending event: [Error: Exception in HostFunction: Malformed calls from JS: field sizes are different.

[[7,22],[1,0],[[320,100,1699451079816,false]],4268]]

@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 Nov 8, 2023
@krystofwoldrich
Copy link
Member

@dnl-jst Thank you for the message, as mentioned above you can try Release build then it will work.

Although the root of the issue is not in the SDK we are working on a fix.

@yogendrajs
Copy link

I'm also having this issue for Android debug mode (not for iOS), will try it in release mode. If there's any update regarding this, please post a comment. Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Archived in project