File tree Expand file tree Collapse file tree 2 files changed +14
-0
lines changed
packages/tailwindcss-language-server/src Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,9 @@ interface SearchFilesOptions {
5
5
/** The directory to search in */
6
6
root : string
7
7
8
+ /** The maximum time to wait for the search to complete */
9
+ timeout : number
10
+
8
11
/** A list of patterns to include */
9
12
include : string [ ]
10
13
@@ -26,7 +29,13 @@ export async function searchFiles(opts: SearchFilesOptions) {
26
29
{ dot : true } ,
27
30
)
28
31
32
+ let controller = new AbortController ( )
33
+ let timer = setTimeout ( ( ) => controller . abort ( ) , opts . timeout )
34
+
29
35
let crawler = new fdir ( {
36
+ // Let us cancel the search if it takes too long
37
+ signal : controller . signal ,
38
+
30
39
// onlyFiles: true
31
40
includeDirs : false ,
32
41
excludeFiles : false ,
@@ -59,5 +68,7 @@ export async function searchFiles(opts: SearchFilesOptions) {
59
68
60
69
let results = await crawler . crawl ( opts . root ) . withPromise ( )
61
70
71
+ clearTimeout ( timer )
72
+
62
73
return results
63
74
}
Original file line number Diff line number Diff line change @@ -279,6 +279,9 @@ export class ProjectLocator {
279
279
root : this . base ,
280
280
include : [ `**/${ CONFIG_GLOB } ` , `**/${ CSS_GLOB } ` ] ,
281
281
exclude : this . settings . tailwindCSS . files . exclude ,
282
+
283
+ // If searching takes more than 15 seconds, abort the search
284
+ timeout : 15 ,
282
285
} )
283
286
284
287
let realpaths = await Promise . all ( files . map ( ( file ) => fs . realpath ( file ) ) )
You can’t perform that action at this time.
0 commit comments