Repository navigation
Conversation
…rod-mode entry Mirrors PR #4132's fix for langgraph-typescript. Dev-mode `npx tsx agent/index.ts` at container boot was doing a fresh in-process TS compile on every cold start, routinely blowing past the 180s watchdog grace on Railway cold containers — same failure class that #4132 fixed for langgraph-typescript. Push the TS compile to image build time (matching flags from showcase/packages/claude-sdk-typescript/Dockerfile so starter and package produce equivalent runtime shapes), and run the compiled `/app/dist/agent/index.js` at boot. Cold start is now a straight `node` invocation. Implementation is driven through the shared Dockerfile.typescript template so langgraph-typescript and mastra slots stay untouched; per-slug opt-in lives in getAgentBuildSteps() / getAgentBuildCopy() in generate-starters.ts. Verified with `docker build --platform linux/amd64` locally — tsc compile completes in ~1.4s at image build time.
…e entry Mirrors PR #4132's fix for langgraph-typescript. Dev-mode `npx mastra dev` at container boot was doing a tsx-based build on first request, routinely blowing past the 180s watchdog grace on Railway cold containers — same failure class that #4132 fixed for langgraph-typescript. Push `mastra build` to image build time (bundles the Mastra server into .mastra/output/index.mjs with its own node_modules), and run `node /app/.mastra/output/index.mjs` at boot. Cold start is now a straight `node` invocation. Emitter logic lives in getAgentBuildSteps() / getAgentBuildCopy() in generate-starters.ts alongside the sibling claude-sdk-typescript slot. Verified with `docker build --platform linux/amd64` locally — mastra build step completes in ~12.9s at image build time, producing a self-contained .mastra/output/.
…entation Package-level service claims to listen on :8000 but Railway health probes fail. Narrow the cold-start window by timestamping each phase from entrypoint exec to first /health-serving moment: - entrypoint.sh: print `[entrypoint] pre-node <ISO>` immediately before `node /app/agent_server.js`, pairing with the agent_server.ts prints below to chain timestamps across the exec boundary. - agent_server.ts: print `[agent_server] module loaded <ISO>` before any side-effect imports (so import-time hangs surface distinctly from init-time hangs), `[agent_server] pre-Anthropic <ISO>` right before `new Anthropic(...)`, and include an ISO timestamp in the existing app.listen() callback so we can read the delta directly. No behavior change — only logs added. Next deploy cycle should reveal which phase consumes the budget and whether the failure mode is listen-but-unreachable vs. listen-never-reached.
PR #4132 replaced `langgraph-cli dev` with a direct @langchain/langgraph-api server call in the package. The starter generator copies package agent code into the starter tree, but the starter was not regenerated at merge time. Run `pnpm -C showcase/scripts generate-starters` to pick up: - agent/package.json: add @langchain/langgraph-api pin (1.1.17), @langchain/langgraph-sdk, langchain, tsx, typescript deps; new `start` script invoking `node --import tsx server.mjs` - agent/package-lock.json: regenerated to match - agent/server.mjs: new direct server entrypoint (from the package) Pure regen — no manual edits. Verified with `git diff` that each file matches the equivalent file under showcase/packages/langgraph-typescript/.
jpr5
requested review from
marthakelly,
mme,
ranst91 and
tylerslaton
as code owners
April 21, 2026 22:33
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
📣 Social Copy GeneratorGenerate social media copies (Twitter/X, LinkedIn, Blog Post) for this PR using Claude.
|
Contributor
Author
|
Folding into upcoming body-of-work Docker refactor PR; branch preserved locally. |
7 tasks
jpr5
added a commit
that referenced
this pull request
Apr 22, 2026
…ers, 17 packages (#4147) ## Summary - Rewrite starter Dockerfile templates (`typescript`, `python`, `java`, `dotnet`) as true multi-stage: builder has dev tools, runner is minimal. No `pip`/`npm`/`pnpm`/`tsx`/`*-cli dev` in runtime stages. - Encode prod-mode behaviors for `claude-sdk-typescript`, `mastra`, `langgraph-typescript` directly in the TS template + generator conditionals (folds in the pattern from #4132 for langgraph-ts; adds parallel migration for claude-sdk-ts + mastra). - Regenerate all 17 starter Dockerfiles. - Rewrite all 17 package Dockerfiles to match the template shape (multi-stage, venv builder for Python, 3-stage Python runtime, `USER app`, etc.). - Cold-start instrumentation on `claude-sdk-typescript` package (absorbed from closed PR #4133). - Pin `platforms: linux/amd64` in the showcase deploy workflow (`docker/build-push-action` step) to match what Railway + GHCR require. - Template `README.md` documenting multi-stage conventions, size target, platform mandate, and the `dockerfile_hygiene` probe. - `generate-starters.ts` strips the `langgraph-typescript` starter's dead `server.mjs` + its `start` script (both reference deps only needed in the package's prod-mode path). ## Why Railway cold starts exceed the 180s watchdog grace when the runtime stage boots via `langgraph-cli dev` / `npx mastra dev` / `npx tsx` — the dev-mode work (TS compile, Rollup bundle, native libsql init) blocks the health probe. #4132 proved the fix is to move this to image build time for langgraph-ts. This PR generalizes that shape to all TS starters that need it and reshapes every Dockerfile in the tree so runners no longer carry dev toolchains. Secondary outcomes: - Smaller runtime images (pip/npm toolchain moved to builder only). - Consistent `--platform linux/amd64` pinning end-to-end. - No `pnpm install --frozen-lockfile` in the TS starter template (starters are no-lockfile by design). - `validate-pins` ratchet re-baselined to match the regenerated spec strings. ## Test plan - [ ] `docker build --platform linux/amd64` green for every starter (17) and package (17) locally - [ ] `pnpm -C showcase/scripts` vitest: 1085/1085 pass - [ ] `tsc --noEmit -p showcase/scripts/tsconfig.json` clean - [ ] `oxfmt --check` + `oxlint` clean on touched TS files - [ ] validate-pins: count 110, hash matches updated baseline - [ ] CI Showcase Validate green on PR HEAD - [ ] Post-merge: showcase deploy for mastra + claude-sdk-typescript goes green (currently flapping)
2 of 3 tasks
zeekay
pushed a commit
to Dream-AI-4444/CopilotKit
that referenced
this pull request
Sep 11, 2026
…ers, 17 packages (CopilotKit#4147) ## Summary - Rewrite starter Dockerfile templates (`typescript`, `python`, `java`, `dotnet`) as true multi-stage: builder has dev tools, runner is minimal. No `pip`/`npm`/`pnpm`/`tsx`/`*-cli dev` in runtime stages. - Encode prod-mode behaviors for `claude-sdk-typescript`, `mastra`, `langgraph-typescript` directly in the TS template + generator conditionals (folds in the pattern from CopilotKit#4132 for langgraph-ts; adds parallel migration for claude-sdk-ts + mastra). - Regenerate all 17 starter Dockerfiles. - Rewrite all 17 package Dockerfiles to match the template shape (multi-stage, venv builder for Python, 3-stage Python runtime, `USER app`, etc.). - Cold-start instrumentation on `claude-sdk-typescript` package (absorbed from closed PR CopilotKit#4133). - Pin `platforms: linux/amd64` in the showcase deploy workflow (`docker/build-push-action` step) to match what Railway + GHCR require. - Template `README.md` documenting multi-stage conventions, size target, platform mandate, and the `dockerfile_hygiene` probe. - `generate-starters.ts` strips the `langgraph-typescript` starter's dead `server.mjs` + its `start` script (both reference deps only needed in the package's prod-mode path). ## Why Railway cold starts exceed the 180s watchdog grace when the runtime stage boots via `langgraph-cli dev` / `npx mastra dev` / `npx tsx` — the dev-mode work (TS compile, Rollup bundle, native libsql init) blocks the health probe. CopilotKit#4132 proved the fix is to move this to image build time for langgraph-ts. This PR generalizes that shape to all TS starters that need it and reshapes every Dockerfile in the tree so runners no longer carry dev toolchains. Secondary outcomes: - Smaller runtime images (pip/npm toolchain moved to builder only). - Consistent `--platform linux/amd64` pinning end-to-end. - No `pnpm install --frozen-lockfile` in the TS starter template (starters are no-lockfile by design). - `validate-pins` ratchet re-baselined to match the regenerated spec strings. ## Test plan - [ ] `docker build --platform linux/amd64` green for every starter (17) and package (17) locally - [ ] `pnpm -C showcase/scripts` vitest: 1085/1085 pass - [ ] `tsc --noEmit -p showcase/scripts/tsconfig.json` clean - [ ] `oxfmt --check` + `oxlint` clean on touched TS files - [ ] validate-pins: count 110, hash matches updated baseline - [ ] CI Showcase Validate green on PR HEAD - [ ] Post-merge: showcase deploy for mastra + claude-sdk-typescript goes green (currently flapping)
This branch was successfully deployed
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
node /app/dist/agent/index.jsat boot (was:npx tsx agent/index.ts).mastra buildat image build,node /app/.mastra/output/index.mjsat boot (was:npx mastra dev).Why
Mirrors #4132 (langgraph-typescript). Dev-mode cold start exceeds 180s watchdog grace on Railway cold containers, producing 502 smoke test failures. Grace bumps do not fix it — the dev-time work (tsx-based compile / mastra rollup) needs to move to image build time so boot is a straight
nodeinvocation.Per-slug opt-in lives in
getAgentBuildSteps()/getAgentBuildCopy()inshowcase/scripts/generate-starters.ts. Other TS starters (langgraph-typescript, etc.) get empty substitutions and their Dockerfile cache surface is unchanged.Test plan
docker build --platform linux/amd64green locally for starter-claude-sdk-typescript (tsc ~1.4s), starter-mastra (mastra build ~12.9s), and package-claude-sdk-typescript.pnpm -C showcase/scripts test— 1079/1079 pass (2 tests updated to assert new prod-mode behavior).pnpm -C showcase/scripts validate-pins— FAIL count held at 110, hash matchesfail-baseline.json(no drift, no baseline update needed).showcase-starter-claude-sdk-typescriptandshowcase-starter-mastra.showcase-package-claude-sdk-typescriptreveal which phase consumes the 180s+ budget (pre-node / module-load / pre-Anthropic / listening timestamps).