chenglou/pretext · error · Error
Generated bidi data is stale: ${outputPath}
Error message
Generated bidi data is stale: ${outputPath} What it means
Thrown only when the generator runs with the `--check` flag. It rebuilds the expected bidi-data.ts from the bundled DerivedBidiClass source and string-compares it against the currently checked-in src/generated/bidi-data.ts. A mismatch means the committed generated artifact is out of sync with either the Unicode source or the generator logic. This is a CI gate, not a runtime failure.
Source
Thrown at scripts/generate-bidi-data.ts:223
export const nonLatin1BidiRanges: readonly (readonly [number, number, GeneratedBidiType])[] = [
${rangeRows},
]
`
}
const scriptsDir = dirname(fileURLToPath(import.meta.url))
const sourceFile = join(scriptsDir, 'unicode', 'DerivedBidiClass-17.0.0.txt')
const generatedDir = join(scriptsDir, '..', 'src', 'generated')
const outputPath = join(generatedDir, 'bidi-data.ts')
const sourceText = readFileSync(sourceFile, 'utf8')
const payload = buildPayload(sourceText)
const nextSource = buildSource(payload, 'scripts/unicode/DerivedBidiClass-17.0.0.txt')
if (process.argv.includes('--check')) {
const currentSource = readFileSync(outputPath, 'utf8')
if (currentSource !== nextSource) {
throw new Error(`Generated bidi data is stale: ${outputPath}`)
}
console.log(`Generated bidi data is up to date (${payload.unicodeVersion}).`)
} else {
mkdirSync(generatedDir, { recursive: true })
await Bun.write(outputPath, nextSource)
console.log(`Wrote ${outputPath} (${payload.unicodeVersion}).`)
}
View on GitHub (pinned to ac49b09b7d)
Solutions
- Run `bun run generate:bidi-data` WITHOUT the `--check` flag to regenerate src/generated/bidi-data.ts.
- Commit the regenerated file alongside the source change that caused the drift.
- Re-run the `--check` variant to confirm it now reports 'up to date'.
Example fix
// before — CI step runs the stale check and fails bun run generate:bidi-data -- --check // after — regenerate first, commit the output, then the check passes bun run generate:bidi-data git add src/generated/bidi-data.ts git commit
Defensive patterns
Strategy: validation
Validate before calling
// CI: regenerate, then diff; only fail if the regeneration produced uncommitted changes
import { execSync } from 'node:child_process'
execSync('bun run generate:bidi-data', { stdio: 'inherit' })
const dirty = execSync('git status --porcelain src/generated/bidi-data.ts').toString().trim()
if (dirty) throw new Error('Generated bidi data changed after regen — commit it') Prevention
- Always run `bun run generate:bidi-data` (no --check) after touching the generator or the Unicode source, then commit.
- Keep the `--check` invocation as a CI-only gate, not a local workflow.
When it happens
Trigger: Running the bidi-data generator with `--check` after editing the generator (scripts/generate-bidi-data.ts), after swapping in a new DerivedBidiClass-*.txt file, or after changing GENERATED_TYPES/longBidiNames/bnProjectedTypes — without then regenerating and committing the output.
Common situations: A contributor updates the Unicode source file in a PR but forgets to re-run the generator; or a refactor of buildSource/buildPayload changes formatting; CI then fails on the stale-check step.
Related errors
- Could not determine Unicode version from DerivedBidiClass he
- Built HTML not found for ${relativePath}
- Invalid code point range: ${raw}
- Unsupported bidi class ${raw}
- Missing pre-wrap result for ${testCase.label}
AI-assisted analysis of chenglou/pretext@ac49b09b7d (2026-08-12).
Data as JSON: /api/errors/6e18f56715bbc090.
Report an issue: GitHub.