Repository navigation
fix(deploy): add cheerio to srv-mcp deps + widen bundle-externals guard - #2537
Merged
Merged
Conversation
…d to all bare externals
srv-mcp crashed at boot on DEV with ERR_MODULE_NOT_FOUND for 'cheerio' because
core.bundle.mjs and mcp.bundle.mjs import cheerio transitively (external, not
inlined by esbuild) but srv-mcp/package.json did not declare it.
This is the same class of bug as the 2026-09-28 @sap-ai-sdk/orchestration incident
in srv-qa, but for a third-party package that the narrow guard (which only checked
@sap-ai-sdk/* and @sap/* prefixes) missed.
Changes:
1. srv-mcp/package.json: add "cheerio": "^1.2.0" (matches root + srv-qa version).
2. scripts/check-bundle-externals-declared.cjs: widen the guard from @sap-ai-sdk/
and @sap/ prefixes to ALL bare external import specifiers in every *.bundle.mjs,
excluding Node.js builtins (detected via require('module').builtinModules with
node: prefix stripping) and relative imports. The regex now matches only lines
that begin with `import` (the esbuild external form) to avoid false positives
from `from "..."` inside string literals in the bundle body. The guard also
handles `srv` (which has no own package.json) by falling back to the root-level
package.json via a pkgOverride in MODULE_DIRS.
3. scripts/__tests__/check-bundle-externals-declared.test.ts: update existing 18
tests to reflect widened scope; add isBareExternal tests; add regression test
for the srv-mcp cheerio incident (pre-fix catches it, post-fix passes).
Widened guard run against all 3 modules after bundle rebuild: exit 0.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
tutorials-srv-mcpcrashed at CF boot withERR_MODULE_NOT_FOUND: Cannot find package 'cheerio' imported from srv/lib/_shared/core.bundle.mjs. The esbuildcorebundle importscheerioas an external, butsrv-mcp/package.jsonnever declared it, so the CF nodejs buildpack didn't install it.The T22 externals guard was too narrow — it only checked
@sap*-scoped externals, so third-party externals likecheerioslipped through and only surfaced as a runtime boot crash.What
srv-mcp/package.json— add"cheerio": "^1.2.0"(matches root + srv-qa).scripts/check-bundle-externals-declared.cjs— widen from@sap*-prefix-only to all bare external imports: skip Node builtins (require('module').builtinModules+node:strip) and relative imports; check every remaining bare import against the consuming module'spackage.jsondeps.srv(no own package.json) checks against root viapkgOverride.scripts/__tests__/check-bundle-externals-declared.test.ts— 33 tests (was 18); adds anisBareExternalsuite, a cheerio-missing violation test, and a2026-09-29: srv-mcp missing cheerioregression pair (pre-fix catches it, post-fix passes).Verification
node scripts/bundle-shared.cjs && node scripts/check-bundle-externals-declared.cjs→ exit 0.vitest run→ 70 files, 1049 tests passed.Last deploy blocker before the T13 PKCE acceptance gate.