@@ -7,8 +7,6 @@ import { isAbsolute } from "path";
77import { getURLOrigin } from "get-url-origin" ;
88import pMemoize from "p-memoize" ;
99import PQueue from "p-queue" ;
10- import * as http from "http" ;
11- import * as https from "https" ;
1210import type { TextlintRuleReporter } from "@textlint/types" ;
1311import type { TxtNode } from "@textlint/ast-node-types" ;
1412
@@ -22,7 +20,6 @@ export type Options = {
2220 concurrency : number ; // {number} Concurrency count of linting link [Experimental]
2321 interval : number ; // The length of time in milliseconds before the interval count resets. Must be finite. [Experimental]
2422 intervalCap : number ; // The max number of runs in the given interval of time. [Experimental]
25- keepAlive : boolean ; // {boolean} if it is true, use keepAlive for checking request [Experimental]
2623 userAgent : string ; // {String} a UserAgent,
2724 maxRetryTime : number ; // (number) The max of waiting seconds for retry. It is related to `retry` option. It does affect to `Retry-After` header.
2825 maxRetryAfterTime : number ; // (number) The max of waiting seconds for `Retry-After` header.
@@ -37,7 +34,6 @@ const DEFAULT_OPTIONS: Options = {
3734 concurrency : 8 , // {number} Concurrency count of linting link [Experimental]
3835 interval : 500 , // The length of time in milliseconds before the interval count resets. Must be finite. [Experimental]
3936 intervalCap : 8 , // The max number of runs in the given interval of time. [Experimental]
40- keepAlive : false , // {boolean} if it is true, use keepAlive for checking request [Experimental]
4137 userAgent : "textlint-rule-no-dead-link/1.0" , // {String} a UserAgent,
4238 maxRetryTime : 10 , // (number) The max of waiting seconds for retry. It is related to `retry` option. It does affect to `Retry-After` header.
4339 maxRetryAfterTime : 10 // (number) The max of waiting seconds for `Retry-After` header.
@@ -106,28 +102,7 @@ function waitTimeMs(ms: number) {
106102 } ) ;
107103}
108104
109- const keepAliveAgents = {
110- http : new http . Agent ( { keepAlive : true } ) ,
111- https : new https . Agent ( { keepAlive : true } )
112- } ;
113-
114105const createFetchWithRuleDefaults = ( ruleOptions : Options ) => {
115- /**
116- * Use library agent, avoid to use global.http(s)Agent
117- * Want to avoid Socket hang up
118- * @param parsedURL
119- * @returns {module:http.Agent|null|module:https.Agent }
120- */
121- const getAgent = ( parsedURL : URL ) => {
122- if ( ! ruleOptions . keepAlive ) {
123- return ;
124- }
125- if ( parsedURL . protocol === "http:" ) {
126- return keepAliveAgents . http ;
127- }
128- return keepAliveAgents . https ;
129- } ;
130-
131106 return ( uri : string , fetchOptions : RequestInit ) => {
132107 const { host } = URL . parse ( uri ) ;
133108 return fetch ( uri , {
@@ -150,9 +125,7 @@ const createFetchWithRuleDefaults = (ruleOptions: Options) => {
150125 Host : host
151126 }
152127 : { } )
153- } ,
154- // custom http(s).agent
155- agent : getAgent
128+ }
156129 } ) ;
157130 } ;
158131} ;
0 commit comments