Skip to content

Commit f550c72

Browse files
committed
fix watchers never being cleaned up
Previously, there was an issue, where a slow compilation could cause the watchers to build up and never be cleaned. This would result in both excessive logging and the compilation time increasing exponentially. This fix is a naive patch, simply locking if there is a build in progress, and unlocking when it completes.
1 parent 88b9f15 commit f550c72

File tree

1 file changed

+6
-0
lines changed
  • packages/@tailwindcss-cli/src/commands/build

1 file changed

+6
-0
lines changed

packages/@tailwindcss-cli/src/commands/build/index.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,16 +237,21 @@ export async function handle(args: Result<ReturnType<typeof options>>) {
237237

238238
let [compiler, scanner] = await handleError(() => createCompiler(input, I))
239239

240+
let lock = false
241+
240242
// Watch for changes
241243
if (args['--watch']) {
242244
let cleanupWatchers = await createWatchers(
243245
watchDirectories(scanner),
244246
async function handle(files) {
245247
try {
248+
if (lock) return
246249
// If the only change happened to the output file, then we don't want to
247250
// trigger a rebuild because that will result in an infinite loop.
248251
if (files.length === 1 && files[0] === args['--output']) return
249252

253+
lock = true
254+
250255
using I = new Instrumentation()
251256
DEBUG && I.start('[@tailwindcss/cli] (watcher)')
252257

@@ -362,6 +367,7 @@ export async function handle(args: Result<ReturnType<typeof options>>) {
362367
eprintln(err.toString())
363368
}
364369
}
370+
lock = false
365371
},
366372
)
367373

0 commit comments

Comments
 (0)