Conversation
There was a problem hiding this comment.
No issues found across 2 files
Since this is your first cubic review, here's how it works:
- cubic automatically reviews your code and comments on bugs and improvements
- Teach cubic by replying to its comments. cubic learns from your replies and gets better over time
- Ask questions if you need clarification on any suggestion
|
@coterp Thank you for contribution! @hayescode @sandangel I would like to review this PR myself, as I tried to implement such functionality earlier and had an issues with that |
|
@hayescode Sounds good, thanks for your review. |
There was a problem hiding this comment.
@coterp Unfortunately I have same issue with it as when I tried implement such feature myself: it doesn't work in Cypress interactive mode, at least on Linux
Try to:
- Open Cypress in interactive mode (for example, via
pnpm test:interactive) - Run
custom_themetests (you'll see green screen, then red) - Run
data_layertests (you'll see green screen again and tests will fail because login isn't enabled in previous test server, while it is indata_layertest server)
|
But I think we can merge some implements from here, like broken entrypoint file existence check, if you'll remove or fix new server restart code |
|
Thanks for the reproduction steps and feedback. That helps clarify the scope. Given that the restart behavior only affects Cypress interactive mode on Linux and isn’t something I can easily validate in my current dev container setup, I think the safest approach is to split this PR and drop the restart changes for now, keeping only the clearly correct fixes. I should be able to push that split as early as tomorrow, though it may slip into early next week depending on availability. |
|
I went ahead and tried to reproduce the issue in Cypress interactive mode on Linux at commit I’m running on RHEL 9.7. Could you share which browser and distro/desktop you’re using? I’ll try to match it. |
|
@coterp Happy holidays! I'm using Ubuntu 24.04 and running Cypress via |
|
Thanks! I hope you had happy holidays as well! Quick update: I set up a test environment on Ubuntu 24.04 and still wasn’t able to reproduce the behavior you mentioned. I tried running the specs in rapid succession to rule out timing issues, tested with both Electron and Chrome, and ran several other specs, but couldn’t get a failure. Let me know if there’s any additional detail I can try to match. |
|
@asvishnyakov No rush, happy to wait or adjust if you still see issues. |
|
Hi @coterp @asvishnyakov, I landed here while investigating the same What I observed: Running The root cause is the same as this PR identifies: I also added a
I also independently found the !access(entryPointPath) dead-code bug in cypress/support/run.ts — access() from fs/promises returns a Promise, so !Promise is always false and the entry-point check never fires. This PR fixes that too by properly awaiting it outside the new Promise() constructor. On the interactive mode concern: @asvishnyakov — the issue you described (switching specs in interactive mode picks up the wrong server config) sounds like it might be a separate Cypress lifecycle concern rather than a problem with the kill/restart approach itself. Suggestion: This PR has been open since December and now has merge conflicts. Would it make sense to:
Happy to help test or contribute if useful. |
|
Thanks @pidefrem, I appreciate the independent confirmation and the extra testing details. @asvishnyakov, I’m happy to rebase this on current |
Is this still relevant? If so, I'm happy to approve and merge once you rebase. (Very little bandwidth to get into the nitty gritty... unfortunately!) |
d8e9a68 to
5235b41
Compare
|
@dokterbob Thanks for taking a look. Yes, I believe this is still relevant. I’ve rebased the PR onto current Thanks again for offering to review and merge it. |
|
@dokterbob The Windows E2E failure appears to be unrelated to this PR. I checked adjacent CI runs and found the same oauth_auth/spec.cy.ts failure in CI #6339 on an unrelated PR and CI #6340 on main. Later runs #6342 and #6343 passed. Could we rerun the failed CI jobs for this PR? |
Summary
This PR improves the reliability of Cypress E2E runs when starting and stopping Chainlit.
Changes
fkill) only as a fallback when no tracked process existsfs/promises.accesswas not awaited)cypress.config.tsnode:+typeimports)Motivation
Cypress E2E runs were failing consistently due to unreliable Chainlit shutdown and restart behavior in containerized dev environments.
Tests frequently failed with port-in-use errors because previous Chainlit instances were not reliably terminated between runs or between specs. The existing port-based termination (
fkill(:port)) proved unreliable in containers and was insufficient as a primary means of terminating Chainlit.This PR introduces explicit process tracking and shutdown of the spawned Chainlit process, using port-based termination only as a fallback to clean up stray instances from previous runs.
Testing
uv run pytest --cov=chainlitpnpm test(Cypress, headless via Xvfb)pnpm test:uipnpm lintSummary by cubic
Cleanly starts and stops Chainlit during Cypress E2E runs to prevent port-in-use errors, especially in containers and on Windows. Previously we relied on port-based
fkilland a non-awaited entrypoint check; now we track the spawned process and kill the process group (or entire tree on Windows) with verified startup.stopChainlit()to terminate the tracked process; usefkill :8000only as a fallback.currentChainlit; handleSIGTERM,SIGINT,SIGHUP, andSIGBREAK, then exit with the correct code after cleanup.taskkill /T /Fand wait briefly to ensure port release; POSIX: sendSIGTERMthenSIGKILLto the process group.fs/promises.access; throw a clear error if the file is missing.restartChainlitwith a flat promise chain and modernizenode:imports and typed error handling.Written for commit 42422c0. Summary will update on new commits.