mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-02-26 09:03:03 +08:00
[client-sync] Add error handling when creating syncback requests
Summary: see title. also convert to es6 Test Plan: manual Reviewers: evan, halla Reviewed By: halla Differential Revision: https://phab.nylas.com/D4225
This commit is contained in:
parent
eb64ae67d2
commit
6532d3c647
1 changed files with 10 additions and 6 deletions
|
@ -1,14 +1,15 @@
|
|||
const _ = require('underscore')
|
||||
const Serialization = require('./serialization');
|
||||
const SyncProcessManager = require('../local-sync-worker/sync-process-manager')
|
||||
import _ from 'underscore'
|
||||
import Boom from 'boom';
|
||||
import Serialization from './serialization';
|
||||
import SyncProcessManager from '../local-sync-worker/sync-process-manager'
|
||||
|
||||
|
||||
const wakeSyncWorker = _.debounce((accountId, reason) => {
|
||||
SyncProcessManager.wakeWorkerForAccount(accountId, {interrupt: true, reason})
|
||||
}, 500)
|
||||
|
||||
module.exports = {
|
||||
async createAndReplyWithSyncbackRequest(request, reply, syncRequestArgs = {}) {
|
||||
export async function createAndReplyWithSyncbackRequest(request, reply, syncRequestArgs = {}) {
|
||||
try {
|
||||
const account = request.auth.credentials
|
||||
const {wakeSync = true} = syncRequestArgs
|
||||
syncRequestArgs.accountId = account.id
|
||||
|
@ -21,5 +22,8 @@ module.exports = {
|
|||
}
|
||||
reply(Serialization.jsonStringify(syncbackRequest))
|
||||
return syncbackRequest
|
||||
},
|
||||
} catch (err) {
|
||||
reply(Boom.wrap(err))
|
||||
return null
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue