Atom periodic saving of state taking a really long time


#1

The following call to to save state that atom performs periodically is taking about 5 seconds to run for one of my projects and it blocking the UI. This started happening a few days ago.

//In class StateStore
save (key, value) {
    return new Promise((resolve, reject) => {
      this.dbPromise.then((db) => {
        if (db == null) return resolve()

        var request = db.transaction(['states'], 'readwrite')
          .objectStore('states')
          .put({value: value, storedAt: new Date().toString()}, key)

        request.onsuccess = resolve
        request.onerror = reject
      })
    })

}

Also, this call may be made async as to not block the UI while.


#2

If you’re referring to this:

It uses IndexedDB which is only accessible asynchronously. Additionally, all of that stuff you see about Promises? That’s one way of writing asynchronous code.

What can you tell us about the project that takes a really long time? What’s different about it from your other projects?


#3

Thanks for the reply. I’m not sure what about the project is different. I’ve been using atom on it for a long time and it just started happening out of nowhere. I should have been more clear that the exact line that it’s blocking on in is:

  var request = db.transaction(['states'], 'readwrite')
    .objectStore('states')
    .put({value: value, storedAt: new Date().toString()}, key)

which is not async.


#4

I was able to figure out the problem. I had a plugin (go-to-line) that was putting a really large object on the state (value) object. Reading the state object was what was taking a long time to do.


#5

Sorry the package causing the issue was ‘goto package.’ Also, I was able to clear the state by launching Atom with --clear-window-state