Skip to content

Commit 8b0d224

Browse files
Fix CLI client crash when a file is removed before we process the change notification (#14616)
Fixes #14613 Don't crash when trying to read the modification time of a file that might already be deleted. Note: This fix is purely theoretical right now as I wasn't able to reproduce the issue yet. --------- Co-authored-by: Jordan Pittman <[email protected]>
1 parent b1733ac commit 8b0d224

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

CHANGELOG.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1111

1212
- Add support for `tailwindcss/colors.js`, `tailwindcss/defaultTheme.js`, and `tailwindcss/plugin.js` exports ([#14595](https://github.com/tailwindlabs/tailwindcss/pull/14595))
1313
- Support `keyframes` in JS config file themes ([#14594](https://github.com/tailwindlabs/tailwindcss/pull/14594))
14-
- _Experimental_: The upgrade tool now automatically discovers your JavaScript config ([#14597](https://github.com/tailwindlabs/tailwindcss/pull/14597))
14+
- _Upgrade (experimental)_: The upgrade tool now automatically discovers your JavaScript config ([#14597](https://github.com/tailwindlabs/tailwindcss/pull/14597))
1515

1616
### Fixed
1717

1818
- Don’t crash when scanning a candidate equal to the configured prefix ([#14588](https://github.com/tailwindlabs/tailwindcss/pull/14588))
1919
- Ensure there's always a space before `!important` when stringifying CSS ([#14611](https://github.com/tailwindlabs/tailwindcss/pull/14611))
20+
- Don't set `display: none` on elements that use `hidden="until-found"` ([#14631](https://github.com/tailwindlabs/tailwindcss/pull/14631))
21+
- Fix issue that could cause the CLI to crash when files are deleted while watching ([#14616](https://github.com/tailwindlabs/tailwindcss/pull/14616))
2022
- _Upgrade (experimental)_: Ensure CSS before a layer stays unlayered when running codemods ([#14596](https://github.com/tailwindlabs/tailwindcss/pull/14596))
2123
- _Upgrade (experimental)_: Resolve issues where some prefixed candidates were not properly migrated ([#14600](https://github.com/tailwindlabs/tailwindcss/pull/14600))
22-
- Don't set `display: none` on elements that use `hidden="until-found"` ([#14631](https://github.com/tailwindlabs/tailwindcss/pull/14631))
2324

2425
## [4.0.0-alpha.26] - 2024-10-03
2526

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

+6-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { compile, env } from '@tailwindcss/node'
33
import { clearRequireCache } from '@tailwindcss/node/require-cache'
44
import { Scanner, type ChangedContent } from '@tailwindcss/oxide'
55
import { Features, transform } from 'lightningcss'
6-
import { existsSync } from 'node:fs'
6+
import { existsSync, type Stats } from 'node:fs'
77
import fs from 'node:fs/promises'
88
import path from 'node:path'
99
import type { Arg, Result } from '../../utils/args'
@@ -346,8 +346,11 @@ async function createWatchers(dirs: string[], cb: (files: string[]) => void) {
346346
if (event.type === 'delete') return
347347

348348
// Ignore directory changes. We only care about file changes
349-
let stats = await fs.lstat(event.path)
350-
if (stats.isDirectory()) {
349+
let stats: Stats | null = null
350+
try {
351+
stats = await fs.lstat(event.path)
352+
} catch {}
353+
if (!stats?.isFile() && !stats?.isSymbolicLink()) {
351354
return
352355
}
353356

0 commit comments

Comments
 (0)