mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-01-01 13:14:16 +08:00
fix(send): Don't retry send
Summary: - There are some cases in which constantly retrying send can cause unexpected bugs like sending multiple times, so don't retry send at all - Make 429 a permanent error code Test Plan: Manual Reviewers: jackie, evan Reviewed By: jackie, evan Differential Revision: https://phab.nylas.com/D3177
This commit is contained in:
parent
b33ca08585
commit
e699b28a36
5 changed files with 3 additions and 19 deletions
|
@ -377,15 +377,6 @@ describe('SendDraftTask', function sendDraftTask() {
|
|||
}));
|
||||
});
|
||||
|
||||
it("retries on timeouts", () => {
|
||||
const thrownError = new APIError({statusCode: NylasAPI.TimeoutErrorCodes[0], body: "err"});
|
||||
spyOn(NylasAPI, 'makeRequest').andReturn(Promise.reject(thrownError));
|
||||
|
||||
waitsForPromise(() => this.task.performRemote().then((status) => {
|
||||
expect(status).toBe(Task.Status.Retry);
|
||||
}));
|
||||
});
|
||||
|
||||
describe("checking the promise chain halts on errors", () => {
|
||||
beforeEach(() => {
|
||||
spyOn(NylasEnv, 'reportError');
|
||||
|
|
|
@ -168,7 +168,7 @@ describe('SyncbackModelTask', function syncbackModelTask() {
|
|||
|
||||
it("retries on retry-able API errors", () => {
|
||||
jasmine.unspy(NylasAPI, "makeRequest");
|
||||
const err = new APIError({statusCode: 429});
|
||||
const err = new APIError({statusCode: 420});
|
||||
spyOn(NylasAPI, "makeRequest").andReturn(Promise.reject(err))
|
||||
performRemote((status) => {
|
||||
expect(status).toBe(Task.Status.Retry)
|
||||
|
|
|
@ -14,7 +14,7 @@ async = require 'async'
|
|||
# A 0 code is when an error returns without a status code. These are
|
||||
# things like "ESOCKETTIMEDOUT"
|
||||
TimeoutErrorCodes = [0, "ETIMEDOUT", "ESOCKETTIMEDOUT", "ECONNRESET", "ENETDOWN", "ENETUNREACH"]
|
||||
PermanentErrorCodes = [400, 401, 402, 403, 404, 405, 500, "ENOTFOUND", "ECONNREFUSED", "EHOSTDOWN", "EHOSTUNREACH"]
|
||||
PermanentErrorCodes = [400, 401, 402, 403, 404, 405, 429, 500, "ENOTFOUND", "ECONNREFUSED", "EHOSTDOWN", "EHOSTUNREACH"]
|
||||
CancelledErrorCode = [-123, "ECONNABORTED"]
|
||||
SampleTemporaryErrorCode = 504
|
||||
|
||||
|
|
|
@ -33,10 +33,7 @@ export default class MultiSendToIndividualTask extends Task {
|
|||
// dozens of these tasks. The `MultieSendSessionCloseTask`
|
||||
// accumulates and shows the errors.
|
||||
if (err instanceof APIError) {
|
||||
if (NylasAPI.PermanentErrorCodes.includes(err.statusCode)) {
|
||||
return Promise.resolve([Task.Status.Failed, err]);
|
||||
}
|
||||
return Promise.resolve(Task.Status.Retry);
|
||||
return Promise.resolve([Task.Status.Failed, err]);
|
||||
}
|
||||
return Promise.resolve([Task.Status.Failed, err]);
|
||||
});
|
||||
|
|
|
@ -239,10 +239,6 @@ export default class SendDraftTask extends BaseDraftTask {
|
|||
let message = err.message;
|
||||
|
||||
if (err instanceof APIError) {
|
||||
if (!NylasAPI.PermanentErrorCodes.includes(err.statusCode)) {
|
||||
return Promise.resolve(Task.Status.Retry);
|
||||
}
|
||||
|
||||
message = `Sorry, this message could not be sent. Please try again, and make sure your message is addressed correctly and is not too large.`;
|
||||
if (err.statusCode === 402 && err.body.message) {
|
||||
if (err.body.message.indexOf('at least one recipient') !== -1) {
|
||||
|
|
Loading…
Reference in a new issue