fix(unplugin): serialize concurrent CSS writes in Bun plugin - #1845
fix(unplugin): serialize concurrent CSS writes in Bun plugin#1845ryuhzk wants to merge 1 commit into
Conversation
|
Hi @ryuhzk! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks! |
|
@ryuhzk is attempting to deploy a commit to the Meta Open Source Team on Vercel. A member of the Team first needs to authorize it. |
f1f09ef to
e8f7bc0
Compare
Summary
When building multi-file projects with Bun, StyleX transforms run concurrently via
onLoad. Each transform triggers an asynchronouswriteCsscall against the sharedcssOutputfile.Previously, those writes were not queued.
lastCsswas updated beforefsp.writeFilecompleted, and callers did not wait on any in-flight write. Concurrent races could therefore produce out-of-order disk writes (an earlier partial CSS snapshot overwriting a later complete one). Separately, ifonEndobservednext === lastCss, it skipped rewriting even when the file on disk still held a stale or incomplete result from an unfinished earlier write.Solution
writeQueue) so each write waits for the previous one to finish.lastCssshort-circuit for intermediate updates, but return the in-flight queue so callers still await completion.force: truefrombuild.onEndso the final collected CSS is always flushed after transforms finish.Test plan
packages/@stylexjs/unpluginJest suite (yarn test) — 17/17 passedstylex.dev.css(or configuredbunDevCssOutput) ends with the complete StyleX CSS after parallelonLoadtransforms