Skip to content

test(build): pin the bundler flag to OMNIROUTE_USE_TURBOPACK, the contract it implements - #11583

Merged
diegosouzapw merged 2 commits into
diegosouzapw:release/v3.8.51from
ntdatt812:fix/bundler-flag-contract-drift
Aug 26, 2026
Merged

diegosouzapw merged 2 commits into
diegosouzapw:release/v3.8.51from
ntdatt812:fix/bundler-flag-contract-drift

Conversation

@ntdatt812

Copy link
Copy Markdown
Contributor

The red test

Unit Tests fast-path fails on every branch:

✖ resolveNextBuildBundlerFlag automatically disables Turbopack and uses Webpack under Bun
  AssertionError [ERR_ASSERTION]: Expected values to be strictly equal:
    actual:   '--turbopack'
    expected: '--webpack'

Why I concluded the test is the stale side

I want to be explicit about this, because "align the assertion to current behaviour" is
exactly how a real defect gets buried, and I nearly left this one alone. The evidence:

  1. The function never implements the rule. resolveNextBuildBundlerFlag does not
    read process.versions.bun — there is no runtime branch to have regressed. As far as
    the (squashed) history goes back, there never was one.
  2. The documented contract disagrees with the test.
    docs/reference/ENVIRONMENT.md describes OMNIROUTE_USE_TURBOPACK as defaulting to
    1, with 0 the escape hatch "on Windows, when running into native binding /
    bundler-compat incompatibilities, or on RAM-constrained machines". No Bun clause.
  3. Every webpack fallback in CI is memory-motivated, not Bun-motivated.
    nightly-compat.yml pins 0 with a long comment about a Node 26 OOM kill on the
    runner; electron-release.yml pins 0 for the linux matrix leg. build.yml,
    ci.yml and quality.yml all pin 1.
  4. Nothing in the repo builds under Bun. bun appears only in
    check:known-symbols and test:bun:db. There is no next build path that runs on it.
  5. The test's second assertion is the strongest tell: it demands that an explicit
    OMNIROUTE_USE_TURBOPACK=1 be ignored under Bun. That directly contradicts the
    variable being the operator's control — and CI is an operator that sets it to 1.

If I have this backwards — if Turbopack genuinely cannot build under Bun < 1.4 —
then the fix belongs in resolveNextBuildBundlerFlag as a version gate, not in the
test, and I will happily rewrite this PR that way. Say the word. What I did not want to
do is leave the gate red on a contradiction nobody had adjudicated.

What this PR does

Rewrites the case to pin the contract the function actually implements, and to keep a
real guard rather than just going green:

for (const bun of [undefined, "1.1.20", "1.3.14"]) {
  …
  resolveNextBuildBundlerFlag({})                                → "--turbopack"
  resolveNextBuildBundlerFlag({ OMNIROUTE_USE_TURBOPACK: "1" })  → "--turbopack"
  resolveNextBuildBundlerFlag({ OMNIROUTE_USE_TURBOPACK: "0" })  → "--webpack"
}

Three runtimes × three env states. A hidden runtime-sniffing override cannot come back
without failing here, and the assertion message names the runtime it fired on. The old
assertion could not have caught that — it demanded the override this now forbids.

The function's comment said "Turbopack is the default (on Node.js and Bun 1.4+)", which
is what made the stale assertion look load-bearing. Nothing implements that version
gate, so the comment now states the env-only rule and why it is env-only.

Verification

# base branch
✖ resolveNextBuildBundlerFlag automatically disables Turbopack and uses Webpack under Bun
ℹ tests 4  ℹ pass 3  ℹ fail 1

# with this change
ℹ tests 4  ℹ pass 4  ℹ fail 0

The new guard bites. I re-added a runtime override by hand
(if (process.versions.bun) return "--webpack"; above the env check):

✖ resolveNextBuildBundlerFlag is decided by OMNIROUTE_USE_TURBOPACK alone, not by the runtime
  AssertionError [ERR_ASSERTION]: bun=1.1.20
    actual:   '--webpack'
    expected: '--turbopack'
npx eslint <both files>   # 0 errors
npx prettier --write      # clean

I deliberately left one pre-existing formatting deviation in bun-support.test.ts
untouched (prettier wants to expand the dummyBunDb.query literal) so the diff stays
on the case being fixed.

No behaviour change: the only production edit is a comment.

…tract it implements

`Unit Tests fast-path` is red on every branch:

    ✖ resolveNextBuildBundlerFlag automatically disables Turbopack and uses Webpack under Bun
      actual: '--turbopack', expected: '--webpack'

The test asserts a Bun-specific override that `resolveNextBuildBundlerFlag` does not
implement — it never reads `process.versions.bun` — including that an explicit
`OMNIROUTE_USE_TURBOPACK=1` is ignored under Bun. That contradicts the documented
contract: `docs/reference/ENVIRONMENT.md` describes the variable as the operator's
control, defaulting to Turbopack, with `0` as the escape hatch for Windows /
native-binding trouble / RAM-constrained machines (diegosouzapw#6409). Every webpack fallback in CI
is memory-motivated (nightly-compat pins `0` for a Node 26 OOM), none is Bun-motivated,
and nothing in the repo runs `next build` under Bun at all.

Rewrites the case to pin what the function implements, across bun-absent / 1.1.20 /
1.3.14 and all three env states, so a hidden runtime-sniffing override cannot come back
without failing here — and the failure names the runtime it fired on. The stale
assertion could not have done that: it demanded the very override this now forbids.

The function's comment said "Turbopack is the default (on Node.js and Bun 1.4+)", which
is what made the old assertion look load-bearing. Nothing implements that version gate,
so the comment now states the env-only rule and why it is env-only.
@diegosouzapw
diegosouzapw merged commit 0a79221 into diegosouzapw:release/v3.8.51 Aug 26, 2026
10 of 16 checks passed
diegosouzapw pushed a commit that referenced this pull request Aug 26, 2026
Merged via /merge-batch (lote 2026-08-26 batch 2, v3.8.51). 7 conflitos, todos triviais/duplicados (mesmos base-reds já corrigidos por PRs paralelas mergeadas neste lote — #11580/#11582/#11583/#11585/#11588/#11589/#11590/#11591/#11609): mantida a versão já validada nesses casos. Validado: 68/68 testes passando. Obrigado por resolver os base-reds.
muhamadgalihsaputra pushed a commit to niyatna/NiyatnaRoute that referenced this pull request Sep 27, 2026
…tract it implements (diegosouzapw#11583)

Merged via /merge-batch (lote 2026-08-26, v3.8.51). Boarded no worktree combinado junto com outras ~30 PRs; validação única: typecheck/complexity/cognitive-complexity/changelog-integrity verdes, file-size rebaseado onde necessário (crescimento legítimo), lint com os mesmos 228 achados pré-existentes confirmados via sonda contra o tip puro (não introduzidos por este lote), e ~370 testes focados (unit + vitest) passando. Obrigado pela contribuição.
muhamadgalihsaputra pushed a commit to niyatna/NiyatnaRoute that referenced this pull request Sep 27, 2026
…osouzapw#11608)

Merged via /merge-batch (lote 2026-08-26 batch 2, v3.8.51). 7 conflitos, todos triviais/duplicados (mesmos base-reds já corrigidos por PRs paralelas mergeadas neste lote — diegosouzapw#11580/diegosouzapw#11582/diegosouzapw#11583/diegosouzapw#11585/diegosouzapw#11588/diegosouzapw#11589/diegosouzapw#11590/diegosouzapw#11591/diegosouzapw#11609): mantida a versão já validada nesses casos. Validado: 68/68 testes passando. Obrigado por resolver os base-reds.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants