[client-sync] Correctly remove sync worker reference when destroying it

Summary:
By nullifying the key inside `workersByAccountId` we would attempt to
access accountIds that no longer existed in other parts of the code by
using Object.keys()

This makes it so we correctly completely remove the record from the map

Test Plan: manual

Reviewers: halla, spang, mark

Reviewed By: mark

Differential Revision: https://phab.nylas.com/D4426
This commit is contained in:
Juan Tejada 2017-04-14 00:58:20 -07:00
parent c6f7a862c9
commit 373eb9651b

View file

@ -173,7 +173,7 @@ class SyncProcessManager {
async removeWorkerForAccountId(accountId, {timeout} = {}) {
if (this._workersByAccountId[accountId]) {
await this._workersByAccountId[accountId].destroy({timeout})
this._workersByAccountId[accountId] = null;
delete this._workersByAccountId[accountId];
}
if (this._localSyncDeltaEmittersByAccountId.has(accountId)) {