diff options
author | Chocobozzz <me@florianbigard.com> | 2021-06-14 18:06:58 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-06-15 08:21:31 +0200 |
commit | 7500d6c9000b531fda1fd64e188b7cf83803941a (patch) | |
tree | 4329c72654b0d6526366cf47de588b7c7d72e073 /server/lib/activitypub | |
parent | 3d470a530c4a48b2e4f4a9e7d4f223e14f32cea4 (diff) | |
download | PeerTube-7500d6c9000b531fda1fd64e188b7cf83803941a.tar.gz PeerTube-7500d6c9000b531fda1fd64e188b7cf83803941a.tar.zst PeerTube-7500d6c9000b531fda1fd64e188b7cf83803941a.zip |
Use a global request timeout
Diffstat (limited to 'server/lib/activitypub')
-rw-r--r-- | server/lib/activitypub/actors/webfinger.ts | 4 | ||||
-rw-r--r-- | server/lib/activitypub/crawl.ts | 7 |
2 files changed, 4 insertions, 7 deletions
diff --git a/server/lib/activitypub/actors/webfinger.ts b/server/lib/activitypub/actors/webfinger.ts index cf8eddfc7..723fca586 100644 --- a/server/lib/activitypub/actors/webfinger.ts +++ b/server/lib/activitypub/actors/webfinger.ts | |||
@@ -1,7 +1,7 @@ | |||
1 | import * as WebFinger from 'webfinger.js' | 1 | import * as WebFinger from 'webfinger.js' |
2 | import { isTestInstance } from '@server/helpers/core-utils' | 2 | import { isTestInstance } from '@server/helpers/core-utils' |
3 | import { isActivityPubUrlValid } from '@server/helpers/custom-validators/activitypub/misc' | 3 | import { isActivityPubUrlValid } from '@server/helpers/custom-validators/activitypub/misc' |
4 | import { WEBSERVER } from '@server/initializers/constants' | 4 | import { REQUEST_TIMEOUT, WEBSERVER } from '@server/initializers/constants' |
5 | import { ActorModel } from '@server/models/actor/actor' | 5 | import { ActorModel } from '@server/models/actor/actor' |
6 | import { MActorFull } from '@server/types/models' | 6 | import { MActorFull } from '@server/types/models' |
7 | import { WebFingerData } from '@shared/models' | 7 | import { WebFingerData } from '@shared/models' |
@@ -10,7 +10,7 @@ const webfinger = new WebFinger({ | |||
10 | webfist_fallback: false, | 10 | webfist_fallback: false, |
11 | tls_only: isTestInstance(), | 11 | tls_only: isTestInstance(), |
12 | uri_fallback: false, | 12 | uri_fallback: false, |
13 | request_timeout: 3000 | 13 | request_timeout: REQUEST_TIMEOUT |
14 | }) | 14 | }) |
15 | 15 | ||
16 | async function loadActorUrlOrGetFromWebfinger (uriArg: string) { | 16 | async function loadActorUrlOrGetFromWebfinger (uriArg: string) { |
diff --git a/server/lib/activitypub/crawl.ts b/server/lib/activitypub/crawl.ts index 278abf7de..cd117f571 100644 --- a/server/lib/activitypub/crawl.ts +++ b/server/lib/activitypub/crawl.ts | |||
@@ -3,7 +3,7 @@ import { URL } from 'url' | |||
3 | import { ActivityPubOrderedCollection } from '../../../shared/models/activitypub' | 3 | import { ActivityPubOrderedCollection } from '../../../shared/models/activitypub' |
4 | import { logger } from '../../helpers/logger' | 4 | import { logger } from '../../helpers/logger' |
5 | import { doJSONRequest } from '../../helpers/requests' | 5 | import { doJSONRequest } from '../../helpers/requests' |
6 | import { ACTIVITY_PUB, REQUEST_TIMEOUT, WEBSERVER } from '../../initializers/constants' | 6 | import { ACTIVITY_PUB, WEBSERVER } from '../../initializers/constants' |
7 | 7 | ||
8 | type HandlerFunction<T> = (items: T[]) => (Promise<any> | Bluebird<any>) | 8 | type HandlerFunction<T> = (items: T[]) => (Promise<any> | Bluebird<any>) |
9 | type CleanerFunction = (startedDate: Date) => (Promise<any> | Bluebird<any>) | 9 | type CleanerFunction = (startedDate: Date) => (Promise<any> | Bluebird<any>) |
@@ -13,10 +13,7 @@ async function crawlCollectionPage <T> (argUrl: string, handler: HandlerFunction | |||
13 | 13 | ||
14 | logger.info('Crawling ActivityPub data on %s.', url) | 14 | logger.info('Crawling ActivityPub data on %s.', url) |
15 | 15 | ||
16 | const options = { | 16 | const options = { activityPub: true } |
17 | activityPub: true, | ||
18 | timeout: REQUEST_TIMEOUT | ||
19 | } | ||
20 | 17 | ||
21 | const startDate = new Date() | 18 | const startDate = new Date() |
22 | 19 | ||