fix(backend): 処理に失敗するとidempotentキーを削除してしまいその後のリクエストが通ってしまう問題を修正 (MisskeyIO#591)

This commit is contained in:
まっちゃとーにゅ 2024-04-01 18:44:44 +09:00 committed by GitHub
parent 92bdc2e054
commit 31ebd77e8a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 79 additions and 8 deletions

View file

@ -173,8 +173,8 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
logger.info('Successfully created drive file.', { fileId: driveFile.id });
return await this.driveFileEntityService.pack(driveFile, me, { self: true });
} catch (e) {
// エラーが発生した場合、リクエストの処理結果を削除
await this.redisClient.unlink(`drive:files:create:idempotent:${me.id}:${hash}`);
// エラーが発生した場合、まだ処理中として記録されている場合はリクエストの処理結果を削除
await this.redisClient.unlinkIf(`drive:files:create:idempotent:${me.id}:${hash}`, '_');
logger.error('Failed to create drive file.', { error: e });

View file

@ -117,8 +117,8 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
});
},
async err => {
// エラーが発生した場合、リクエストの処理結果を削除
await this.redisClient.unlink(`drive:files:upload-from-url:idempotent:${me.id}:${hash}`);
// エラーが発生した場合、まだ処理中として記録されている場合はリクエストの処理結果を削除
await this.redisClient.unlinkIf(`drive:files:upload-from-url:idempotent:${me.id}:${hash}`, '_');
logger.error('Failed to upload from URL.', { error: err });
},
);

View file

@ -445,8 +445,8 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
createdNote: await this.noteEntityService.pack(note, me),
};
} catch (err) {
// エラーが発生した場合、リクエストの処理結果を削除
await this.redisForTimelines.unlink(`note:idempotent:${me.id}:${hash}`);
// エラーが発生した場合、まだ処理中として記録されている場合はリクエストの処理結果を削除
await this.redisForTimelines.unlinkIf(`note:idempotent:${me.id}:${hash}`, '_');
logger.error('Failed to create a note.', { error: err });