-
-
Notifications
You must be signed in to change notification settings - Fork 879
Description
Bug Report
I just updated to oxfmt: 0.36.0, and I sometimes had errors when linting css files, it did not happen everytime.
I asked claude to investigate, and here is what it found.
I though it might be worthy of a github issue, hope it helps 🙏
Summary
When running oxfmt --check (or --write) on a project containing CSS files, random CSS files fail with:
× TypeError: Cannot use 'in' operator to search for 'importer' in undefined
│ [path/to/some/file.css]The crash is non-deterministic — different CSS files fail per run (and between local/CI environments), which strongly points to a race condition in the worker thread pool.
Workaround
Running with --threads=1 eliminates the crash entirely:
oxfmt --check ./ --threads=1 # passes on all 2286 filesRoot Cause (analysis)
The CSS parser is registered in prettier-plugin-tailwindcss's createPlugin call inside dist/dist-BIcAktiQ.js:
// dist-BIcAktiQ.js (line 14904)
defineTransform({
load: [postcss_exports], // <-- postcss plugin reference
parsers: { css: {}, scss: {}, less: {} },
transform: transformCss
})postcss_exports is imported from ./angular-BYaMjeNY.js, which itself imports from ./dist-BIcAktiQ.js — a circular ESM dependency:
dist-BIcAktiQ.js → angular-BYaMjeNY.js → dist-BIcAktiQ.js
In the main thread this resolves correctly via ESM live bindings. However, when worker threads (cli-worker.js) initialize their own module graph, the circular dependency causes postcss_exports to evaluate as undefined in some workers.
When loadPlugin(source) is then called with that undefined value:
// dist-BIcAktiQ.js (line 14204)
async function loadPlugin(source) {
if ("importer" in source && ...) // ← throws TypeError when source === undefinedThe check "importer" in undefined throws the observed TypeError.
Steps to Reproduce
- Create a project with several CSS files
- Enable
sortTailwindcssin.oxfmtrc.json(triggers the postcss plugin path) - Run
oxfmt --check ./with default thread count - Observe random CSS files failing with the
TypeError - Run again with
--threads=1— all files pass
Environment
| oxfmt | 0.36.0 |
| OS | macOS Darwin 25.3.0 arm64 |
| Node | v24.13.1 |
| Bun | 1.3.10 |
Expected Behavior
CSS files should format/check successfully regardless of the number of worker threads used.
Suggested Fix
Either:
- Guard
loadPluginagainstundefined:if (source && "importer" in source ...) - Break the circular ESM dependency between
dist-BIcAktiQ.jsandangular-BYaMjeNY.jssopostcss_exportsis always defined in worker contexts