Uploaded image for project: 'Apache Cordova'
  1. Apache Cordova
  2. CB-14181

Cannot read property 'filesystemName' of null

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • cordova@7.0.0
    • None
    • cordova-plugin-file
    • cordova 7.1.0

    Description

      Error in Success callbackId: File1539060614 : TypeError: Cannot read property 'filesystemName' of null
      cordova.js:314 Uncaught TypeError: Cannot read property 'filesystemName' of null

      The `fsRoot` might be null. reproduced with latest cordova on android emulator.

       

      This is the problematic line : https://github.com/apache/cordova-plugin-file/blob/master/www/fileSystems-roots.js#L33

      PR : https://github.com/apache/cordova-plugin-file/pull/235

      Attachments

        Issue Links

          Activity

            jcesarmobile jcesarmobile added a comment -

            The PR makes sense, but how can it be reproduced?

            jcesarmobile jcesarmobile added a comment - The PR makes sense, but how can it be reproduced?
            githubbot ASF GitHub Bot added a comment -

            shazron commented on issue #235: CB-14181: (android) Fix bug - Cannot read property 'filesystemName' of null
            URL: https://github.com/apache/cordova-plugin-file/pull/235#issuecomment-401215199

            There are eslint issues with this patch, see Travis CI build logs. Run `npm test` you will see them.

            ----------------------------------------------------------------
            This is an automated message from the Apache Git Service.
            To respond to the message, please log on GitHub and use the
            URL above to go to the specific comment.

            For queries about this service, please contact Infrastructure at:
            users@infra.apache.org

            githubbot ASF GitHub Bot added a comment - shazron commented on issue #235: CB-14181 : (android) Fix bug - Cannot read property 'filesystemName' of null URL: https://github.com/apache/cordova-plugin-file/pull/235#issuecomment-401215199 There are eslint issues with this patch, see Travis CI build logs. Run `npm test` you will see them. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: users@infra.apache.org
            githubbot ASF GitHub Bot added a comment -

            jony89 commented on issue #235: CB-14181: (android) Fix bug - Cannot read property 'filesystemName' of null
            URL: https://github.com/apache/cordova-plugin-file/pull/235#issuecomment-401316370

            fixed, yet I see tests are failing and they fail in all other PR's as well.

            ----------------------------------------------------------------
            This is an automated message from the Apache Git Service.
            To respond to the message, please log on GitHub and use the
            URL above to go to the specific comment.

            For queries about this service, please contact Infrastructure at:
            users@infra.apache.org

            githubbot ASF GitHub Bot added a comment - jony89 commented on issue #235: CB-14181 : (android) Fix bug - Cannot read property 'filesystemName' of null URL: https://github.com/apache/cordova-plugin-file/pull/235#issuecomment-401316370 fixed, yet I see tests are failing and they fail in all other PR's as well. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: users@infra.apache.org
            githubbot ASF GitHub Bot added a comment -

            jcesarmobile commented on issue #235: CB-14181: (android) Fix bug - Cannot read property 'filesystemName' of null
            URL: https://github.com/apache/cordova-plugin-file/pull/235#issuecomment-401317107

            This will prevent the error, but what will cause the "Cannot read property 'filesystemName' of null"? How can this be reproduced?

            ----------------------------------------------------------------
            This is an automated message from the Apache Git Service.
            To respond to the message, please log on GitHub and use the
            URL above to go to the specific comment.

            For queries about this service, please contact Infrastructure at:
            users@infra.apache.org

            githubbot ASF GitHub Bot added a comment - jcesarmobile commented on issue #235: CB-14181 : (android) Fix bug - Cannot read property 'filesystemName' of null URL: https://github.com/apache/cordova-plugin-file/pull/235#issuecomment-401317107 This will prevent the error, but what will cause the "Cannot read property 'filesystemName' of null"? How can this be reproduced? ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: users@infra.apache.org
            githubbot ASF GitHub Bot added a comment -

            jony89 commented on issue #235: CB-14181: (android) Fix bug - Cannot read property 'filesystemName' of null
            URL: https://github.com/apache/cordova-plugin-file/pull/235#issuecomment-401337457

            @jcesarmobile it has been reproduced to me constantly on android emulator nexus 5

            device - nexus 5
            android 7.1.1 nougat (yet will be reproduced on oreo as well I'm sure)
            cordova 7.1.0

            with the following code from the blog - documentation (caused on the line `fs.root.getFile`

            ```js
            window.requestFileSystem(window.LocalFileSystem.TEMPORARY, 0, (fs) => {
            console.log('file system open: ' + fs.name);
            fs.root.getFile(
            `${window.cordova.file.applicationStorageDirectory}${this.fileName}`,

            { create: true, exclusive: false }

            , (fileEntry) => {
            console.log('fileEntry is file? ' + fileEntry.isFile.toString());
            var oReq = new XMLHttpRequest();
            // Make sure you add the domain name to the Content-Security-Policy <meta> element.
            oReq.open('GET', cvURL, true);
            // Define how you want the XHR data to come back
            oReq.responseType = 'blob';
            oReq.onload = (oEvent) => {
            var blob = oReq.response; // Note: not oReq.responseText
            if (blob) {
            // Create a URL based on the blob, and set an <img> tag's src to it.
            var url = window.URL.createObjectURL(blob);
            document.getElementById('bot-img').src = url;
            // Or read the data with a FileReader
            var reader = new FileReader();
            reader.addEventListener('loadend', () =>

            { // reader.result contains the contents of blob as text }

            );
            reader.readAsText(blob);
            } else console.error('we didnt get an XHR response!');
            };
            oReq.send(null);
            }, function (err)

            { console.error('error getting file! ' + err); }

            );
            }, function (err)

            { console.error('error getting persistent fs! ' + err); }

            );
            ```

            ----------------------------------------------------------------
            This is an automated message from the Apache Git Service.
            To respond to the message, please log on GitHub and use the
            URL above to go to the specific comment.

            For queries about this service, please contact Infrastructure at:
            users@infra.apache.org

            githubbot ASF GitHub Bot added a comment - jony89 commented on issue #235: CB-14181 : (android) Fix bug - Cannot read property 'filesystemName' of null URL: https://github.com/apache/cordova-plugin-file/pull/235#issuecomment-401337457 @jcesarmobile it has been reproduced to me constantly on android emulator nexus 5 device - nexus 5 android 7.1.1 nougat (yet will be reproduced on oreo as well I'm sure) cordova 7.1.0 with the following code from the blog - documentation (caused on the line `fs.root.getFile` ```js window.requestFileSystem(window.LocalFileSystem.TEMPORARY, 0, (fs) => { console.log('file system open: ' + fs.name); fs.root.getFile( `${window.cordova.file.applicationStorageDirectory}${this.fileName}`, { create: true, exclusive: false } , (fileEntry) => { console.log('fileEntry is file? ' + fileEntry.isFile.toString()); var oReq = new XMLHttpRequest(); // Make sure you add the domain name to the Content-Security-Policy <meta> element. oReq.open('GET', cvURL, true); // Define how you want the XHR data to come back oReq.responseType = 'blob'; oReq.onload = (oEvent) => { var blob = oReq.response; // Note: not oReq.responseText if (blob) { // Create a URL based on the blob, and set an <img> tag's src to it. var url = window.URL.createObjectURL(blob); document.getElementById('bot-img').src = url; // Or read the data with a FileReader var reader = new FileReader(); reader.addEventListener('loadend', () => { // reader.result contains the contents of blob as text } ); reader.readAsText(blob); } else console.error('we didnt get an XHR response!'); }; oReq.send(null); }, function (err) { console.error('error getting file! ' + err); } ); }, function (err) { console.error('error getting persistent fs! ' + err); } ); ``` ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: users@infra.apache.org
            githubbot ASF GitHub Bot added a comment -

            jcesarmobile commented on issue #235: CB-14181: (android) Fix bug - Cannot read property 'filesystemName' of null
            URL: https://github.com/apache/cordova-plugin-file/pull/235#issuecomment-401559251

            I couldn't reproduce with that code on real devices or the emulator.
            Anyway, the code is ok, going to merge.

            But what should worry us is why root is null on first place.
            As you can reproduce, would be good if you can investigate and create a new issue with more information about what might cause the root to be null.

            ----------------------------------------------------------------
            This is an automated message from the Apache Git Service.
            To respond to the message, please log on GitHub and use the
            URL above to go to the specific comment.

            For queries about this service, please contact Infrastructure at:
            users@infra.apache.org

            githubbot ASF GitHub Bot added a comment - jcesarmobile commented on issue #235: CB-14181 : (android) Fix bug - Cannot read property 'filesystemName' of null URL: https://github.com/apache/cordova-plugin-file/pull/235#issuecomment-401559251 I couldn't reproduce with that code on real devices or the emulator. Anyway, the code is ok, going to merge. But what should worry us is why root is null on first place. As you can reproduce, would be good if you can investigate and create a new issue with more information about what might cause the root to be null. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: users@infra.apache.org
            githubbot ASF GitHub Bot added a comment -

            jcesarmobile closed pull request #235: CB-14181: (android) Fix bug - Cannot read property 'filesystemName' of null
            URL: https://github.com/apache/cordova-plugin-file/pull/235

            This is a PR merged from a forked repository.
            As GitHub hides the original diff on merge, it is displayed below for
            the sake of provenance:

            As this is a foreign pull request (from a fork), the diff is supplied
            below (as it won't show otherwise due to GitHub magic):

            diff --git a/www/fileSystems-roots.js b/www/fileSystems-roots.js
            index 9a3fc7a..b15adbd 100644
            — a/www/fileSystems-roots.js
            +++ b/www/fileSystems-roots.js
            @@ -30,8 +30,10 @@ require('./fileSystems').getFs = function (name, callback) {
            fsMap = {};
            for (var i = 0; i < response.length; ++i) {
            var fsRoot = response[i];

            • var fs = new FileSystem(fsRoot.filesystemName, fsRoot);
            • fsMap[fs.name] = fs;
              + if (fsRoot) { + var fs = new FileSystem(fsRoot.filesystemName, fsRoot); + fsMap[fs.name] = fs; + }

              }
              callback(fsMap[name]);
              }

            ----------------------------------------------------------------
            This is an automated message from the Apache Git Service.
            To respond to the message, please log on GitHub and use the
            URL above to go to the specific comment.

            For queries about this service, please contact Infrastructure at:
            users@infra.apache.org

            githubbot ASF GitHub Bot added a comment - jcesarmobile closed pull request #235: CB-14181 : (android) Fix bug - Cannot read property 'filesystemName' of null URL: https://github.com/apache/cordova-plugin-file/pull/235 This is a PR merged from a forked repository. As GitHub hides the original diff on merge, it is displayed below for the sake of provenance: As this is a foreign pull request (from a fork), the diff is supplied below (as it won't show otherwise due to GitHub magic): diff --git a/www/fileSystems-roots.js b/www/fileSystems-roots.js index 9a3fc7a..b15adbd 100644 — a/www/fileSystems-roots.js +++ b/www/fileSystems-roots.js @@ -30,8 +30,10 @@ require('./fileSystems').getFs = function (name, callback) { fsMap = {}; for (var i = 0; i < response.length; ++i) { var fsRoot = response [i] ; var fs = new FileSystem(fsRoot.filesystemName, fsRoot); fsMap [fs.name] = fs; + if (fsRoot) { + var fs = new FileSystem(fsRoot.filesystemName, fsRoot); + fsMap[fs.name] = fs; + } } callback(fsMap [name] ); } ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: users@infra.apache.org

            Commit cc3aedb0abb220b4c4ede7c48af5e578fd071690 in cordova-plugin-file's branch refs/heads/master from jony89
            [ https://gitbox.apache.org/repos/asf?p=cordova-plugin-file.git;h=cc3aedb ]

            CB-14181: (android) Fix bug - Cannot read property 'filesystemName' of null (#235)

            CB-14181: (android) fix: Cannot read property 'filesystemName' of null

            fix error :

            Error in Success callbackId: File1539060614 : TypeError: Cannot read property 'filesystemName' of null
            cordova.js:314 Uncaught TypeError: Cannot read property 'filesystemName' of null

            The `fsRoot` might be null. reproduced with latest cordova on android emulator.

            • fix: eslint
            jira-bot ASF subversion and git services added a comment - Commit cc3aedb0abb220b4c4ede7c48af5e578fd071690 in cordova-plugin-file's branch refs/heads/master from jony89 [ https://gitbox.apache.org/repos/asf?p=cordova-plugin-file.git;h=cc3aedb ] CB-14181 : (android) Fix bug - Cannot read property 'filesystemName' of null (#235) CB-14181 : (android) fix: Cannot read property 'filesystemName' of null fix error : Error in Success callbackId: File1539060614 : TypeError: Cannot read property 'filesystemName' of null cordova.js:314 Uncaught TypeError: Cannot read property 'filesystemName' of null The `fsRoot` might be null. reproduced with latest cordova on android emulator. fix: eslint

            Commit cc3aedb0abb220b4c4ede7c48af5e578fd071690 in cordova-plugin-file's branch refs/heads/master from jony89
            [ https://gitbox.apache.org/repos/asf?p=cordova-plugin-file.git;h=cc3aedb ]

            CB-14181: (android) Fix bug - Cannot read property 'filesystemName' of null (#235)

            CB-14181: (android) fix: Cannot read property 'filesystemName' of null

            fix error :

            Error in Success callbackId: File1539060614 : TypeError: Cannot read property 'filesystemName' of null
            cordova.js:314 Uncaught TypeError: Cannot read property 'filesystemName' of null

            The `fsRoot` might be null. reproduced with latest cordova on android emulator.

            • fix: eslint
            jira-bot ASF subversion and git services added a comment - Commit cc3aedb0abb220b4c4ede7c48af5e578fd071690 in cordova-plugin-file's branch refs/heads/master from jony89 [ https://gitbox.apache.org/repos/asf?p=cordova-plugin-file.git;h=cc3aedb ] CB-14181 : (android) Fix bug - Cannot read property 'filesystemName' of null (#235) CB-14181 : (android) fix: Cannot read property 'filesystemName' of null fix error : Error in Success callbackId: File1539060614 : TypeError: Cannot read property 'filesystemName' of null cordova.js:314 Uncaught TypeError: Cannot read property 'filesystemName' of null The `fsRoot` might be null. reproduced with latest cordova on android emulator. fix: eslint
            jcesarmobile jcesarmobile added a comment -

            Fixed in 6.0.2-dev

            jcesarmobile jcesarmobile added a comment - Fixed in 6.0.2-dev

            People

              Unassigned Unassigned
              jony89 ari
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - 1h
                  1h
                  Remaining:
                  Remaining Estimate - 1h
                  1h
                  Logged:
                  Time Spent - Not Specified
                  Not Specified