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

Some errors are not being handled in NativeModules genMethod #20364

Closed
2 of 3 tasks
tad-lispy opened this issue Jul 24, 2018 · 3 comments
Closed
2 of 3 tasks

Some errors are not being handled in NativeModules genMethod #20364

tad-lispy opened this issue Jul 24, 2018 · 3 comments
Labels
Stale There has been a lack of activity on this issue and it may be closed soon.

Comments

@tad-lispy
Copy link

Environment

Scanning folders for symlinks in /Users/tadeusz/Projects/kdv/parent-mobile-app/client/node_modules (35ms)

Environment:
  OS: OS X El Capitan 10.11.6
  Node: 10.5.0
  Yarn: 1.2.1
  npm: 6.1.0
  Watchman: Not Found
  Xcode: Not Found
  Android Studio: 3.0 AI-171.4408382

Packages: (wanted => installed)
  react: 16.3.1 => 16.3.1
  react-native: https://github.com/expo/react-native/archive/sdk-28.0.0.tar.gz => 0.55.4

Description

We believe there is a bug somewhere in NativeModules or MessageQueue modules from BatchedBridge library.

In our application we are using Expo SDK v. 28.0.0 which maps to React Native 0.55.4. We run into a bug when calling Expo.FileSystem.downloadAsync which is indirectly calling genMethod from NativeModules of React Native BatchedBridge library. We are getting a Promise back and we are assigning then and catch callbacks to the returned promise. Neither of the callbacks is called.

We have been able to trace the calls down to genMethod function of NativeModules module from react-native package and it seems that the problem is rooted there, or more likely somewhere in BatchedBridge and MessageQueue modules that are being used there:

return new Promise((resolve, reject) => {
  BatchedBridge.enqueueNativeCall(moduleID, methodID, args,
    (data) => resolve(data),
    (errorData) => reject(createErrorFromErrorData(errorData)));
});

Here enqueueNativeCall method is called and executes without any apparent error, but neither of the callbacks set in enqueueNativeCall of NativeModules are ever called, which in consequence leaves the Promise never resolved.

We suspect that we have a bug in our code, specifically we do not ask for permissions to access native API. This however should result in some meaningful error. Instead our async logic flow is just lost without a trace. We believe this is a bug in React Native code rather than Expo.

Reproducible Demo

Application code sample:

Promise
  .resolve(null)
  .then(() => {
    console.log("Promise chain started");
    const promise = FileSystem.downloadAsync(
      target,
      FileSystem.cacheDirectory
    )
    console.log(require('util').inspect(promise, { depth: null }));
    // We see the promise object
    return promise 
    // We are silently loosing our flow here
  })
  .catch((error) => {
    // this is never called
    console.log("Error caught");
    console.log(require('util').inspect(error, { depth: null }));
  })
  .then((downloaded) => {
    // this is never called either
  })
@TheSavior
Copy link
Member

This sounds like an error with the native code for this method not calling the appropriate callbacks on error. If so, that would mean it is an issue in Expo's native module code.

@stale
Copy link

stale bot commented Oct 31, 2018

Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as "For Discussion" or "Good first issue" and I will leave it open. Thank you for your contributions.

@stale stale bot added the Stale There has been a lack of activity on this issue and it may be closed soon. label Oct 31, 2018
@stale
Copy link

stale bot commented Nov 7, 2018

Closing this issue after a prolonged period of inactivity. If this issue is still present in the latest release, please feel free to create a new issue with up-to-date information.

@stale stale bot closed this as completed Nov 7, 2018
@facebook facebook locked as resolved and limited conversation to collaborators Nov 8, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Stale There has been a lack of activity on this issue and it may be closed soon.
Projects
None yet
Development

No branches or pull requests

2 participants