summaryrefslogtreecommitdiff
path: root/src/queue/processors/deliver.ts
diff options
context:
space:
mode:
authorMeiMei <30769358+mei23@users.noreply.github.com>2021-10-16 17:16:24 +0900
committerGitHub <noreply@github.com>2021-10-16 17:16:24 +0900
commit482081c41b45ab3798e73c4d11e8a7c1c1f5e8c9 (patch)
treefed02348c2fce534f8101370853eb83fbf3aa899 /src/queue/processors/deliver.ts
parentテスト用コンテナの調整 (#7838) (diff)
downloadsharkey-482081c41b45ab3798e73c4d11e8a7c1c1f5e8c9.tar.gz
sharkey-482081c41b45ab3798e73c4d11e8a7c1c1f5e8c9.tar.bz2
sharkey-482081c41b45ab3798e73c4d11e8a7c1c1f5e8c9.zip
Refactor request (#7814)
* status code * Test ap-request.ts https://github.com/mei23/crytest/blob/4397fc5e70536e4175fe56e974ca83b8047bef3a/test/ap-request.ts * tune
Diffstat (limited to 'src/queue/processors/deliver.ts')
-rw-r--r--src/queue/processors/deliver.ts7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/queue/processors/deliver.ts b/src/queue/processors/deliver.ts
index 373e57cbd5..3c61896a2f 100644
--- a/src/queue/processors/deliver.ts
+++ b/src/queue/processors/deliver.ts
@@ -11,6 +11,7 @@ import { toPuny } from '@/misc/convert-host';
import { Cache } from '@/misc/cache';
import { Instance } from '@/models/entities/instance';
import { DeliverJobData } from '../types';
+import { StatusError } from '@/misc/fetch';
const logger = new Logger('deliver');
@@ -68,16 +69,16 @@ export default async (job: Bull.Job<DeliverJobData>) => {
registerOrFetchInstanceDoc(host).then(i => {
Instances.update(i.id, {
latestRequestSentAt: new Date(),
- latestStatus: res != null && res.hasOwnProperty('statusCode') ? res.statusCode : null,
+ latestStatus: res instanceof StatusError ? res.statusCode : null,
isNotResponding: true
});
instanceChart.requestSent(i.host, false);
});
- if (res != null && res.hasOwnProperty('statusCode')) {
+ if (res instanceof StatusError) {
// 4xx
- if (res.statusCode >= 400 && res.statusCode < 500) {
+ if (res.isClientError) {
// HTTPステータスコード4xxはクライアントエラーであり、それはつまり
// 何回再送しても成功することはないということなのでエラーにはしないでおく
return `${res.statusCode} ${res.statusMessage}`;