Repository navigation
fix(showcase/langgraph-typescript): bind liveness probe before heavy module imports - #4148
Merged
Merged
Conversation
…module imports PR #4140 placed the liveness probe inside server.mjs under the belief it would bind "synchronously before any await." That is not how ES modules work — all top-level `import` statements resolve before any module-body code runs. `@langchain/langgraph-api/server` takes ~4m30s to cold-import on Railway (graph eval + tsx transpile), but the watchdog's 180s grace + 3x30s strikes = 270s kills the container ~4s before the probe would have bound. Kill-loop forever. Split into: - `src/agent/liveness.mjs` (new entry): binds :8124/ok immediately using only `node:http`, then dynamic-imports server.mjs so the heavy langgraph bootstrap runs AFTER :8124 is already serving 200. - `src/agent/server.mjs`: removed the now-dead sibling-probe code; comment block explains why. - `src/agent/package.json`: `start` script now runs `node --import tsx liveness.mjs` instead of `server.mjs`. - `entrypoint.sh`: comments updated to describe the new ordering. Local smoke (docker build + run on linux/amd64): /ok returns 200 within 1.4s of container launch vs the previous ~4m34s.
jpr5
requested review from
marthakelly,
mme,
ranst91 and
tylerslaton
as code owners
April 22, 2026 05:19
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.
|
zeekay
pushed a commit
to Dream-AI-4444/CopilotKit
that referenced
this pull request
Sep 11, 2026
…module imports (CopilotKit#4148) ## Summary - Split `server.mjs` into `liveness.mjs` (new entry) + `server.mjs` (actual langgraph-api server). - `liveness.mjs` binds `/ok` on :8124 first, then dynamic-imports `server.mjs` to kick off the real langgraph bootstrap. - `src/agent/package.json` `start` script now runs `node --import tsx liveness.mjs` as the entry. ## Why CopilotKit#4140 put the probe inside `server.mjs` under the belief it would bind "synchronously before any await." ES module semantics say otherwise — all top-level `import` declarations resolve before any module-body code runs. Cold start of `@langchain/langgraph-api` + graph transpile takes ~4m30s on Railway, but watchdog grace (180s) + strikes (90s) = 270s kills before the probe ever opens. Dynamic import defers the heavy load until after liveness is already serving 200. ## Test plan - [x] Local Docker build green (amd64) - [x] Container serves /ok within <2s of launch (measured: 1.4s) - [ ] Railway deploy green + smoke passes sustained
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
server.mjsintoliveness.mjs(new entry) +server.mjs(actual langgraph-api server).liveness.mjsbinds/okon :8124 first, then dynamic-importsserver.mjsto kick off the real langgraph bootstrap.src/agent/package.jsonstartscript now runsnode --import tsx liveness.mjsas the entry.Why
#4140 put the probe inside
server.mjsunder the belief it would bind "synchronously before any await." ES module semantics say otherwise — all top-levelimportdeclarations resolve before any module-body code runs. Cold start of@langchain/langgraph-api+ graph transpile takes ~4m30s on Railway, but watchdog grace (180s) + strikes (90s) = 270s kills before the probe ever opens. Dynamic import defers the heavy load until after liveness is already serving 200.Test plan