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

Uncaught #<FileError> in write() when readyState != WRITING ?

VotersWatch issueWatchersLinkUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 4.1.1
    • None
    • cordova-plugin-file
    • Android

    Description

      Excuse me if I did something stupid - I'm new to Cordova and JS.

      I thought that calling write() after checking readyState != WRITING would work.

      function writeQueue(c) {
              while ( !(logWriter.readyState === FileWriter.WRITING) ) {
                  var msg = logQueue.dequeue();
                  if (!msg) {
                      return;
                  }
      
                  var blob = new Blob([msg+c], { type: 'text/plain' });
                  logWriter.write(blob);
              }
          }
      }
      

      But I get:
      0 277161 log log writer: cdvfile://localhost/files/bala.log
      1 277199 log log writer: onwriteend
      2 283616 log log writer: onwriteend
      3 283629 log log writer: onwriteend
      4 283651 error Uncaught #<FileError>, http://192.168.1.200:8100/plugins/cordova-plugin-file/www/FileWriter.js, Line: 130

      Line 130 is:

          // Throw an exception if we are already writing a file
          if (this.readyState === FileWriter.WRITING) {
              throw new FileError(FileError.INVALID_STATE_ERR);
          }
      

      How can readyState change to WRITING ?

      Note: Queue is pure Javascript (http://code.stephenmorley.org/javascript/queues/Queue.src.js)

      Attachments

        1. code.js
          2 kB
          Samo Dadela

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            Unassigned Unassigned
            samo_dadela@hotmail.com Samo Dadela
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment