question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[android] makeDirectoryAsync() succeeds, but still returns error "could not be created"

See original GitHub issue

Environment

Environment: OS: macOS High Sierra 10.13.5 Node: 7.6.0 Yarn: 1.3.2 npm: 4.6.1 Watchman: 4.7.0 Xcode: Xcode 9.4 Build version 9F1027a Android Studio: 2.3 AI-162.4069837

Packages: (wanted => installed) expo: ^28.0.0 => 28.0.0 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

Have only seen the problem on Android so far. Standalone release build downloaded through Play store.

Steps to Reproduce

(Write your steps here:)

  1. Create a directory with makeDirectoryAsync()

Expected Behavior

Expect to receive no error.

Actual Behavior

makeDirectoryAsync() often returns “Error” … “could not be created”. However if I check getInfoAsync() after receiving the error, the directory is actually created.

The last Sentry report about this showed it was a Cubit X15 phone, Android 22.

Reproducible Demo

// Create any app folders that don't already exist
export const checkAndCreateFolder = async folder_path => {
  const folder_info = await Expo.FileSystem.getInfoAsync(folder_path);
  if (!Boolean(folder_info.exists)) {
    // Create folder
    try {
      await FileSystem.makeDirectoryAsync(folder_path, {
        intermediates: true
      });
    } catch (error) {
      // Report folder creation error, include the folder existence before and now
      const new_folder_info = await Expo.FileSystem.getInfoAsync(folder_path);
      const debug = `checkAndCreateFolder: ${
        error.message
      } old:${JSON.stringify(folder_info)} new:${JSON.stringify(
        new_folder_info
      )}`;
      console.log(debug);
      Sentry.captureException(new Error(debug));
    }
  }
};

The Sentry reports show that before creation getInfoAsync() returned:

{"isDirectory":false,"exists":false}

And after makeDirectoryAsync() failed and returned “could not be created” getInfoAsync() shows it actually exists:

{"size":4096,"modificationTime":1532552616,"uri":"file:///data/data/com.test.test/files/ExperienceData/%2540test%252Ftest/subfolder","isDirectory":true,"exists":true}

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
kelvinlawsoncommented, Aug 2, 2018

I made a Snack to try to reproduce, but while doing so it became clear that this is probably a concurrency problem with multiple asynchronous calls the app is making to makeDirectoryAsync() in order to create the same folder.

So the error is probably “Directory already exists” (logging the error number in makeDirectoryAsync() would be handy).

Illustrated by this snack which simplifies it to just two consecutive calls to create the same directory: https://snack.expo.io/Hy1B_YgHQ

0reactions
EvanBaconcommented, Aug 2, 2018

@kelvinlawson Could you please open an issue for the FileSystem module https://github.com/expo/expo-file-system/issues 💙

Read more comments on GitHub >

github_iconTop Results From Across the Web

EXPO Android - makeDirectoryAsync() error “could not be ...
We are getting Sentry reports from our Android customers who get errors during makeDirectoryAsync(). The error is:
Read more >
FileSystem - Expo Documentation
Create a DownloadResumable object which can start, pause, and resume a download of contents at a remote URI to a file in the...
Read more >
error cannot read property 'configurations' of undefined. react ...
enableJetifier=true. And after running command - 'react-native run-android' app build is successful but it still shows the following msg on terminal:.
Read more >
Active questions tagged react-native+ios - Stack Overflow
For that I run 'pod install' within ios folder and caught error: ... error: C compiler cannot create executablesSee `config.log' for more details....
Read more >
How to use the expo-file-system.documentDirectory function in ...
To help you get started, we've selected a few expo-file-system.documentDirectory examples, based on popular ways it is used in public projects.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found