Skip to content

fix(docker): bundle LLMLingua optional dependencies - #9185

Merged
diegosouzapw merged 1 commit into
diegosouzapw:release/v3.8.50from
Zartharas:fix/9166-docker-llmlingua-deps
Aug 6, 2026
Merged

diegosouzapw merged 1 commit into
diegosouzapw:release/v3.8.50from
Zartharas:fix/9166-docker-llmlingua-deps

Conversation

@Zartharas

Copy link
Copy Markdown
Contributor

Summary

  • explicitly install optional dependencies in the Docker builder
  • reuse the existing LLMLingua dependency-closure copier for Next.js standalone bundles
  • preserve packages already traced into the standalone output instead of overwriting pinned versions
  • include the @huggingface/transformers dependency closure so ONNX runtime packages survive final-image assembly
  • fail the Docker build when required LLMLingua packages do not resolve and load from the final standalone tree
  • add focused regression coverage for complete closure copying, no-clobber behavior, and Docker packaging validation

Related Issues

Root Cause

The LLMLingua packages were already present in optionalDependencies and package-lock.json.

The Docker builder installed them in the root node_modules, but the final image copied only .build/next/standalone. Because the LLMLingua engine uses dynamic imports, Next.js tracing did not reliably include the complete optional dependency closure in that standalone bundle.

The existing colocateLlmlinguaOptionals helper targeted dist/node_modules for npm package installations and was not applied to the Docker standalone output.

Validation

Choose the change type and focused loop from the
Contribution Golden Path.

  • Change type: Docker / build packaging

  • Focused tests:

    node --import tsx/esm --test tests/unit/colocate-optionals.test.ts tests/unit/docker-llmlingua-optionals-9166.test.ts

    • 9 passed
    • 0 failed
  • node --check scripts/build/colocateOptionals.mjs

  • node --check scripts/build/assembleStandalone.mjs

  • git diff --check

  • Reconciled with release/v3.8.50 at fc35dc248f46354e80fdcdaa551e6598abcf5124

  • Production-code changes include automated regression tests

  • Full Docker image build — delegated to PR CI because of its substantial local build cost

  • Full lint, unit suite, coverage, production build, and SonarQube analysis — pending PR CI

Tests Added Or Updated

  • existing tests/unit/colocate-optionals.test.ts

    • all six existing compatibility tests continue to pass
  • new tests/unit/docker-llmlingua-optionals-9166.test.ts

    • verifies the complete LLMLingua runtime closure is copied into standalone output
    • verifies an already pinned standalone @huggingface/transformers instance is not overwritten
    • verifies missing dependencies from its closure, including onnxruntime-node, are still copied
    • verifies Docker explicitly installs optional dependencies
    • verifies Docker rejects package resolution outside the final standalone tree
    • verifies required packages and the native ONNX runtime are loaded during image assembly

Reviewer Notes

The generalized colocation helper retains its existing default destination of dist/node_modules, so the npm postinstall behavior remains compatible.

Standalone assembly supplies its own destination and adds @huggingface/transformers as a closure seed. Copying remains no-clobber: packages already present in the standalone bundle keep their traced and pinned versions, while missing transitive dependencies are filled from the builder’s installed dependency tree.

The Docker validation uses a createRequire rooted at the standalone package and verifies every resolved path is under the standalone node_modules. This prevents a false-positive result caused by falling back to the builder’s root /app/node_modules.

@Zartharas
Zartharas marked this pull request as ready for review August 2, 2026 02:35
@Zartharas
Zartharas requested a review from diegosouzapw as a code owner August 2, 2026 02:35
@diegosouzapw
diegosouzapw merged commit d2f3c1a into diegosouzapw:release/v3.8.50 Aug 6, 2026
3 checks passed
diegosouzapw added a commit that referenced this pull request Aug 6, 2026
…ned suites

Continuing the base-red drain on release/v3.8.50.

- src/i18n/messages/{en,pt-BR,vi}.json: #8523's manual-API-key UI calls
  noAuthProvider.providerAdded / .add / .manualApiKey, but the keys were never
  added to en.json — 'direct translation calls have English messages' was red.
  Added to en (source of truth) plus the two parity-tested locales.
  settings-i18n-keys 10/10.
- src/i18n/messages/pt-BR.json: same 3 keys the vi locale was missing
  (providers.onboardingProviderDescriptions.unorouter, agentBridge.noMappingsDesc,
  agentBridge.addMapping), translated. i18n-pt-br 3/3, i18n-vi-completeness 5/5.
- tests/unit/tls-client-node-docker-binary-7802.test.ts: the assertion pinned the
  literal flag list of the builder's npm ci. #9185 inserted --include=optional
  (LLMLingua optional deps) and broke the pin without touching intent, which is
  the --ignore-scripts PRECONDITION. Regex is now flag-order tolerant and still
  requires --ignore-scripts on the same npm ci. 1/1.
- tests/unit/runtime-env.test.ts: #8999 made withRuntimePortEnv also pin the bind
  address (HOSTNAME, defaulting to 0.0.0.0 when OMNIROUTE_HOSTNAME is unset).
  Expectation updated to the real shape. 2/2.

Refs #9298
diegosouzapw added a commit that referenced this pull request Aug 8, 2026
…tion (#9615)

* fix(docker): complete partially traced packages in standalone co-location

Publish-to-Docker-Hub has failed on every release/v3.8.50 push since #9151
enabled publishing from active release branches: the post-build guard dies
with "Cannot find module .../@atjsh/llmlingua-2/dist/index.js" while the
co-location step right above it reports 100 packages copied.

Root cause: Next's file tracing materializes @atjsh/llmlingua-2 PARTIALLY
in the standalone (package.json lands, the dist/ payload its main points at
does not). colocateOptionals' no-clobber checked existsSync on the package
DIRECTORY, so the partial shell counted as present and the one package that
mattered was skipped forever (#9185 added the closure walk but kept the
directory-level check).

Fix: presence is now judged by entrypoint integrity — the package resolves
from inside the target tree (same contract as the Dockerfile guard). Partial
directories are completed with a file-level no-clobber merge (cpSync
force:false), so files the trace did materialize are never overwritten and
pinned instances (dist transformers 3.5.2) keep their protection.

Validation (TDD): 2 new tests in docker-llmlingua-optionals-9166.test.ts
reproduce the CI failure (partial package skipped; closure-wide early-exit
firing while a member is partial) — red on the old code, 5/5 green after.

* fix: update colocate test mock packages to match isPackageIntact entrypoint resolution

The PR's isPackageIntact check uses require.resolve to validate that
co-located packages have a usable entrypoint inside the target tree.
The pre-existing test's mock packages lacked main fields and index
files, so require.resolve failed and the idempotency assertion broke.

Update buildRoot() to give every closure package a resolvable entry
(main + index.js), mirroring what real npm packages ship.

Refs #9615

* docs(changelog): fragment for #9615

* fix(yuanbao-web): accept content field in SSE text events (upstream format change) (#8739)

Closes #8739

* fix(errorClassifier): classify ChatGPT Web SENTINEL_BLOCKED 403 as FORBIDDEN, enabling combo fallback (#8813)

Closes #8813

* fix(vertex): route Claude models to native rawPredict and respect targetFormat overrides (#8994)

Closes #8994

* fix(cursor): preserve tool context across multi-turn conversations when client lacks conversation_id (#9029)

Closes #9029

* fix(sse): move Antigravity client system content to first user message to avoid upstream 429 (#9030)

Closes #9030

* fix(combo): distinguish pre-dispatch skips from genuine failures to prevent false 503 ALL_ACCOUNTS_INACTIVE (#9630)

Closes #9630

* fix: repair stray brace in combo.ts and fix no-explicit-any types in repro-9630 test

---------

Co-authored-by: diegosouzapw <diegosouzapw@users.noreply.github.com>
@Zartharas
Zartharas deleted the fix/9166-docker-llmlingua-deps branch September 24, 2026 13:26
muhamadgalihsaputra pushed a commit to niyatna/NiyatnaRoute that referenced this pull request Sep 27, 2026
Validated in local merge-train T4 (HouMinXi+Zartharas+Andrian+artickc)
muhamadgalihsaputra pushed a commit to niyatna/NiyatnaRoute that referenced this pull request Sep 27, 2026
…tion (diegosouzapw#9615)

* fix(docker): complete partially traced packages in standalone co-location

Publish-to-Docker-Hub has failed on every release/v3.8.50 push since diegosouzapw#9151
enabled publishing from active release branches: the post-build guard dies
with "Cannot find module .../@atjsh/llmlingua-2/dist/index.js" while the
co-location step right above it reports 100 packages copied.

Root cause: Next's file tracing materializes @atjsh/llmlingua-2 PARTIALLY
in the standalone (package.json lands, the dist/ payload its main points at
does not). colocateOptionals' no-clobber checked existsSync on the package
DIRECTORY, so the partial shell counted as present and the one package that
mattered was skipped forever (diegosouzapw#9185 added the closure walk but kept the
directory-level check).

Fix: presence is now judged by entrypoint integrity — the package resolves
from inside the target tree (same contract as the Dockerfile guard). Partial
directories are completed with a file-level no-clobber merge (cpSync
force:false), so files the trace did materialize are never overwritten and
pinned instances (dist transformers 3.5.2) keep their protection.

Validation (TDD): 2 new tests in docker-llmlingua-optionals-9166.test.ts
reproduce the CI failure (partial package skipped; closure-wide early-exit
firing while a member is partial) — red on the old code, 5/5 green after.

* fix: update colocate test mock packages to match isPackageIntact entrypoint resolution

The PR's isPackageIntact check uses require.resolve to validate that
co-located packages have a usable entrypoint inside the target tree.
The pre-existing test's mock packages lacked main fields and index
files, so require.resolve failed and the idempotency assertion broke.

Update buildRoot() to give every closure package a resolvable entry
(main + index.js), mirroring what real npm packages ship.

Refs diegosouzapw#9615

* docs(changelog): fragment for diegosouzapw#9615

* fix(yuanbao-web): accept content field in SSE text events (upstream format change) (diegosouzapw#8739)

Closes diegosouzapw#8739

* fix(errorClassifier): classify ChatGPT Web SENTINEL_BLOCKED 403 as FORBIDDEN, enabling combo fallback (diegosouzapw#8813)

Closes diegosouzapw#8813

* fix(vertex): route Claude models to native rawPredict and respect targetFormat overrides (diegosouzapw#8994)

Closes diegosouzapw#8994

* fix(cursor): preserve tool context across multi-turn conversations when client lacks conversation_id (diegosouzapw#9029)

Closes diegosouzapw#9029

* fix(sse): move Antigravity client system content to first user message to avoid upstream 429 (diegosouzapw#9030)

Closes diegosouzapw#9030

* fix(combo): distinguish pre-dispatch skips from genuine failures to prevent false 503 ALL_ACCOUNTS_INACTIVE (diegosouzapw#9630)

Closes diegosouzapw#9630

* fix: repair stray brace in combo.ts and fix no-explicit-any types in repro-9630 test

---------

Co-authored-by: diegosouzapw <diegosouzapw@users.noreply.github.com>
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.

fix(docker): optional deps (@atjsh/llmlingua-2, @tensorflow/tfjs, js-tiktoken) absent from diegosouzapw/omniroute:latest image

2 participants