File tree 2 files changed +9
-4
lines changed
2 files changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ const config = {
17
17
// default config
18
18
backgroundSyncInterval : 60000 ,
19
19
disableFeatures : [ ] ,
20
- discoveryTimeout : 10000 ,
20
+ discoveryTimeout : 5000 ,
21
21
isBackground : false ,
22
22
requestTimeout : 30000 ,
23
23
syncInterval : 10000
Original file line number Diff line number Diff line change 2
2
3
3
import WebFinger from 'webfinger.js' ;
4
4
import type { StorageInfo } from './interfaces/storage_info' ;
5
+ import config from './config' ;
5
6
import log from './log' ;
6
7
import { globalContext , localStorageAvailable } from './util' ;
7
8
@@ -19,9 +20,9 @@ let cachedInfo = {};
19
20
* This function deals with the Webfinger lookup, discovering a connecting
20
21
* user's storage details.
21
22
*
22
- * @param { string } userAddress - user@host or URL
23
+ * @param userAddress - user@host or URL
23
24
*
24
- * @returns { Promise } A promise for an object with the following properties.
25
+ * @returns A promise for an object with the following properties.
25
26
* href - Storage base URL,
26
27
* storageApi - RS protocol version,
27
28
* authUrl - OAuth URL,
@@ -38,9 +39,13 @@ const Discover = function Discover(userAddress: string): Promise<StorageInfo> {
38
39
const webFinger = new WebFinger ( {
39
40
tls_only : false ,
40
41
uri_fallback : true ,
41
- request_timeout : 5000
42
+ request_timeout : config . discoveryTimeout
42
43
} ) ;
43
44
45
+ setTimeout ( ( ) => {
46
+ return reject ( new Error ( 'timed out' ) ) ;
47
+ } , config . discoveryTimeout ) ;
48
+
44
49
return webFinger . lookup ( userAddress , function ( err , response ) {
45
50
if ( err ) {
46
51
return reject ( err ) ;
You can’t perform that action at this time.
0 commit comments