mirror of
https://github.com/Foundry376/Mailspring.git
synced 2024-09-22 08:16:09 +08:00
fix(send): Correctly wait for send task to complete before succeeding!
Summary: If the worker window were to restart or the app were to close in the middle of a send task, sending to a single recipient, we would not properly await the task and always mark as success. This diff, along with (D3897) should fix T7559. Test Plan: manual Reviewers: spang, mark, evan, halla Reviewed By: mark, evan, halla Maniphest Tasks: T7559 Differential Revision: https://phab.nylas.com/D3895
This commit is contained in:
parent
8d875a6307
commit
1ea9853d12
2
src/K2
2
src/K2
|
@ -1 +1 @@
|
|||
Subproject commit 76ff5752f8a21fb47b1889b8e0fe7f890b027b3b
|
||||
Subproject commit 89a6499f1986c2d79549990c71ef45b4ab0ea39d
|
|
@ -17,26 +17,6 @@ import EnsureMessageInSentFolderTask from './ensure-message-in-sent-folder-task'
|
|||
const OPEN_TRACKING_ID = NylasEnv.packages.pluginIdFor('open-tracking')
|
||||
const LINK_TRACKING_ID = NylasEnv.packages.pluginIdFor('link-tracking')
|
||||
|
||||
/**
|
||||
* TOOD: NOTE: The SendDraft process is extremely sensitive to the worker
|
||||
* window crashing part-way through sending. This will be true until we
|
||||
* unifiy N1 and K2's sync worker systems.
|
||||
*
|
||||
* Unfortunately the sendMessage "API" request is wrapped in
|
||||
* SyncbackTaskAPIRequest. The API task doesn't resolve until the
|
||||
* corresponding SyncbackTask has been processed in K2 and either
|
||||
* succeeded or failed. We only know if this happens based on listening to
|
||||
* the DeltaStream for a SyncbackTask delta.
|
||||
*
|
||||
* If the worker window (where the TaskQueue and K2 live) reboots before
|
||||
* K2 gets around to actually running the task, then our `SendDraftTask`
|
||||
* will be half-way through performRemote when it reboots. The TaskQueue
|
||||
* will attempt to restore from disk, but the fact we were half-way
|
||||
* through the performRemote, and the syncbackRequest handler we were
|
||||
* listening to is currently not saved to disk. This means that
|
||||
* SendDraftTask will never know when or if the corresponding K2
|
||||
* SyncbackTask ever finished.
|
||||
*/
|
||||
export default class SendDraftTask extends BaseDraftTask {
|
||||
|
||||
constructor(draftClientId, {playSound = true, emitError = true, allowMultiSend = true} = {}) {
|
||||
|
@ -117,7 +97,7 @@ export default class SendDraftTask extends BaseDraftTask {
|
|||
_sendWithSingleBody = async () => {
|
||||
let responseJSON = {}
|
||||
if (this._syncbackRequestId) {
|
||||
responseJSON = SyncbackTaskAPIRequest.waitForQueuedRequest(this._syncbackRequestId)
|
||||
responseJSON = await SyncbackTaskAPIRequest.waitForQueuedRequest(this._syncbackRequestId)
|
||||
} else {
|
||||
const task = new SyncbackTaskAPIRequest({
|
||||
api: NylasAPI,
|
||||
|
|
Loading…
Reference in a new issue