fix(ado-script): inline azure-devops-node-api to avoid missing ncc chunk#935
Merged
Merged
Conversation
auth.ts lazy-loaded the SDK via `await import()`. ncc 0.38 splits dynamic imports into separate webpack chunk files (e.g. `485.index.js`) that the flat release layout in `scripts/ado-script/` does not ship, so at runtime `getWebApi()` failed with `Cannot find module .../485.index.js`. Use a static `import * as azdev` so ncc inlines the SDK into every bundle, making each script self-contained. Also fixes the same latent bug in gate.js. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.
Summary
exec-context-pr-synth(and latentlygate.js) crashed at runtime with:Root cause
src/shared/auth.tslazy-loadedazure-devops-node-apiviaawait import("azure-devops-node-api")to defer ~50–100 ms of moduleevaluation on bypass paths. ncc 0.38 compiles dynamic
import()into aseparate webpack chunk file (
<id>.index.js) that lives alongsidethe main bundle in
.ado-build/<name>/. Eachbuild:*script inscripts/ado-script/package.jsononly copiesindex.jsout to the flat<name>.jslayout that the release workflow ships as individual assets(see
src/compile/extensions/ado_script.rs's per-file download list),so the chunk silently vanished. At runtime
getWebApi()triedn.e(485).then(n.t.bind(n, 3485, 23))and Node could not resolve themissing file.
gate.jshad the same chunk-split, but most gate evaluations short-circuit before touching
getWebApi(), so the bug stayed dormant thereuntil
exec-context-pr-synthexercised the ADO REST path on every run.Fix
Replace the dynamic import with a static
import * as azdevinsrc/shared/auth.ts. ncc now inlines the SDK directly into everybundle, so each script ships as a single self-contained file that
matches the flat release layout:
gate.jsimport.jsexec-context-pr.jsexec-context-pr-synth.jsUpdated the doc comment on
auth.tsto record why the import is static(linking the failure mode to the flat release layout) and dropped the
now-stale 30 s vitest timeout in
auth.test.tsthat compensated forthe first-call dynamic-import cost.
Note
No compiler/Rust changes — the broken artefacts only ship via a new
ado-awrelease that bundlesscripts/ado-script/*.jsas releaseassets. A release of
ado-awis required before pipelines pick upthe fix end-to-end.
Test plan
From
scripts/ado-script/:npm run typecheck— cleannpm test— 281/281 passing (34 test files)npm run test:smoke— 6/6 passingnpm run build— all four bundles rebuilt; verified each containszero
n.e(<id>)dynamic chunk loads via a regex sweep over theemitted
*.jsfiles.