Skip to content

Commit

Permalink
Fix postcss client crash when a file is removed before we process the…
Browse files Browse the repository at this point in the history
… change notification
  • Loading branch information
philipp-spiess committed Oct 8, 2024
1 parent 7be5346 commit e076e5f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Don’t crash when scanning a candidate equal to the configured prefix ([#14588](https://github.com/tailwindlabs/tailwindcss/pull/14588))
- Ensure there's always a space before `!important` when stringifying CSS ([#14611](https://github.com/tailwindlabs/tailwindcss/pull/14611))
- Fix an issue that could caused the postcss client to crash when files are deleted
- _Experimental_: Ensure CSS before a layer stays unlayered when running codemods ([#14596](https://github.com/tailwindlabs/tailwindcss/pull/14596))

## [4.0.0-alpha.26] - 2024-10-03
Expand Down
9 changes: 6 additions & 3 deletions packages/@tailwindcss-cli/src/commands/build/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { compile, env } from '@tailwindcss/node'
import { clearRequireCache } from '@tailwindcss/node/require-cache'
import { Scanner, type ChangedContent } from '@tailwindcss/oxide'
import { Features, transform } from 'lightningcss'
import { existsSync } from 'node:fs'
import { existsSync, Stats } from 'node:fs'
import fs from 'node:fs/promises'
import path from 'node:path'
import type { Arg, Result } from '../../utils/args'
Expand Down Expand Up @@ -346,8 +346,11 @@ async function createWatchers(dirs: string[], cb: (files: string[]) => void) {
if (event.type === 'delete') return

// Ignore directory changes. We only care about file changes
let stats = await fs.lstat(event.path)
if (stats.isDirectory()) {
let stats: Stats | null = null
try {
stats = await fs.lstat(event.path)
} catch {}
if (stats?.isDirectory()) {
return
}

Expand Down

0 comments on commit e076e5f

Please sign in to comment.