Which checkout did your dev server actually build?
A branch checkout served the wrong code because an environment variable pinned the build tool’s workspace root somewhere else. The process working directory looked right, so nothing seemed wrong.
How to do it
- Pick the tell before you serve. Name one string that exists only on your branch: a new property, a tag key, a log label. If you cannot name one, you have no way to check what you are looking at.
- Serve the branch, then fetch /main.js from the running page and search it for that string. Minifiers keep property names and tag keys, so the tell survives the build.
- Treat absence as the signal. The run that caught this showed three missing at once: a newly added SDK, an api.duration string and a measuredRowHeight property, all of which the branch had.
- When the bundle is not yours, look for an environment variable that pins the tool’s workspace root. The agent environment here set NX_WORKSPACE_ROOT_PATH to the main checkout, so Nx used that as the root and served the main checkout’s code even though the command ran inside a separate worktree. That checkout sat on an older commit with uncommitted edits.
- Do not trust the process working directory. It still printed the worktree path, which is what hid the problem. The run executor was resolving out of the main repo’s node_modules.
- Serve with the variable removed or repointed: env -u NX_WORKSPACE_ROOT_PATH npx nx serve <app>, or set it to the worktree path. Then run the /main.js check again, because a check on a bundle you did not prove is not a check.
Before you report any manual check as done on a locally served app: print every environment variable that could pin the build tool's workspace root (for Nx that is NX_WORKSPACE_ROOT_PATH) and compare it to the worktree directory I am working in. If they differ, restart the dev server with that variable unset, or set to this worktree. Then fetch /main.js from the running page, grep it for a string that exists only on this branch (a new property name, a tag key, a log label), and paste the matching line. If you cannot find such a string, tell me the check is unproven instead of reporting it as passed.