#1916·stylex

Bun media query parser sometimes consumes EOF token as trailing syntax

Author: schickling-assistantCreated Sep 29, 2026Updated Sep 29, 2026

@stylexjs/babel-plugin rejects valid media queries under Bun with Invalid media query syntax.. The same Babel transform succeeds under Node. This affects both 0.19.0 and 0.19.1; changing the decimal rem condition to another valid media query does not fix it.

Minimal reproduction

https://github.com/schickling-repros/2026-09-stylex-bun-media-eof

bash
bun install
bun repro.mjs
node repro.mjs

Measured with Bun 1.4.2 on Linux x86_64: 196/256 identical valid @media (max-width: 63.99rem) transforms failed in one run; Node 24.20.0: 0/256. Repeated Bun runs vary in failure count.

The Babel plugin's flattenRawStyleObject() catch masks the underlying error from TokenParser.parseToEnd():

Expected end of input, got EOF-token instead
Consumed tokens: at-keyword-token, whitespace-token, (-token, ident-token, colon-token, whitespace-token, dimension-token, )-token

TokenList.peek() in packages/style-value-parser/src/token-types.js trusts tokenIterator.endOfFile() before calling nextToken(), but does not handle TokenType.EOF returned by nextToken(). consumeNextToken() and setCurrentIndex() make the same assumption. Treating an explicit EOF token as end-of-input in those three paths makes 500/500 transforms pass under Bun locally. Could the parser guard against explicit EOF tokens even if endOfFile() was false at the previous check?

Posted on behalf of @schickling
field value
agent_identity dev3.direct.omp.wj3m9rzw
session unknown
agent_persona generalist
agent_supervisor unavailable
agent_tool OMP
agent_tool_version 18.3.4
agent_runtime OMP 18.3.4
agent_model anthropic/claude-opus-5-5
worktree eu-rpc-explorer-stylex/2026-09-29-rpc-explorer-stylex
tooling_profile dotfiles@e79a6b5