title: Conflict in _local
body: <p>Occasionally I am getting something along the lines of:</p>
  
  <blockquote>
    <p><a href="http://myhosted.couchdb.com:5984/userdb-6938/_local/H73d9PBjwCczSUMy4NZ6bA%3D%3D" rel="nofollow">http://myhosted.couchdb.com:5984/userdb-6938/_local/H73d9PBjwCczSUMy4NZ6bA%3D%3D</a>
    409 (Conflict)</p>
  </blockquote>
  
  <p>The header response is: <code>{"error":"conflict","reason":"Document update conflict."}</code></p>
  
  <p>The request payload is: </p>
  
  <pre><code>{
      "_id": "_local/f.kaEuoL4i41KgUTkCHAyg==",
      "_rev": "0-10",
      "session_id": "735AF8E9-BF62-191F-9A63-760C922E1259",
      "history": [{
          "last_seq": 77,
          "session_id": "735AF8E9-BF62-191F-9A63-760C922E1259"
      },
      {
          "last_seq": 67,
          "session_id": "908B46C9-06C4-A60D-9189-CCE33ECEB252"
      },
      {
          "last_seq": 59,
          "session_id": "7B7A1737-D6AB-23F2-B3C3-954DFAC3F91A"
      },
      {
          "last_seq": 52,
          "session_id": "A7B639E5-CCEF-E1DE-91B2-8E27AB4AFB5B"
      },
      {
          "last_seq": 45,
          "session_id": "D8A322C2-5421-D493-91FB-DD85258D2194"
      }],
      "replicator": "pouchdb",
      "version": 1,
      "last_seq": 77
  }
  </code></pre>
  
  <p>This is happening when performing some actions using pouchDb i.e This code will sometimes trigger it:</p>
  
  <pre><code>try {
    await db.bulkDocs(toBeSaved)
  } catch (err) {
    errorCallback(err, importObj)
  }
  </code></pre>
  
  <p>I understand <a href="http://docs.couchdb.org/en/2.0.0/api/local.html" rel="nofollow">local docs</a> are docs that don't get replicated but <strong>do I need to worry about the error message that shows</strong>? The <a href="http://guide.couchdb.org/draft/conflicts.html" rel="nofollow">docs</a> do explain about handling conflicts but this appears to be one I can't do anything about. Also, as this is a bulk operation, which document exactly is causing the conflict?</p>
  
  <p><strong>EDIT</strong> </p>
  
  <p>My getLocalDb call (which sorts the connection to pouch / couch):</p>
  
  <pre><code>getLocalDb: function (onSyncCompleteDispatch) {
      var localDb = new PouchDb(this.databaseName, {auto_compaction: true})
      var liveDb = this.getLiveDb()
      var self = this
  
      // Only send a db object once it has sync'd with the remote host.
      return new Promise(function (resolve, reject) {
        resolve(localDb)
  
        // We're not using continuous sync because the loading bars on the app will go wild
        // We don't need to get data without users clicking anything at this point.
        localDb.sync(liveDb, {
          live: false,
          retry: false
        }).on('complete', function (info) {
          var requiresReload = info.pull.docs_written &gt; 0 || info.pull.docs_read &gt; 0 || info.push.docs_written &gt; 0 || info.push.docs_read &gt; 0
          if (requiresReload) {
            typeof self.onSyncCompleteCallback === 'function' &amp;&amp; self.onSyncCompleteCallback(info)
          }
        }).on('error', function (err) {
          if (err.message === 'getCheckpoint rejected with ') {
            // Don't need to resolve anything here as we resolved it above and nothing will have
            // changed as no connection is available.
            console.log('No live connection available, return local (without sync).')
          } else {
            typeof self.onSyncErrorCallback === 'function' &amp;&amp; self.onSyncErrorCallback(err)
            reject(err)
          }
        })
      })
    }
  </code></pre>