Stop the a11y audit hanging on Windows and auditing a stale preview - #66
Merged
Merged
Conversation
On Windows the audit wrote its report and then never exited, leaving orphaned `astro preview` servers on 4331, 4332 and up. `startPreview()` spawned astro through run-command.ts, which goes through cmd.exe, and `child.kill()` ended only the wrapper. The astro grandchild survived and kept the piped stdout/stderr open, so node stayed alive. One run sat "running" for three hours at under a second of CPU. With an orphan on 4331, `astro preview` quietly moved to the next free port. The script kept polling 4331 and audited the orphan's older build. - astro's own entry point now runs directly under this node, so there is one process to stop. On stop, `taskkill /T /F` on Windows and a process-group kill on POSIX (the child is spawned detached) take the whole tree. The pipes are then destroyed and the child unref'd. The same kill runs on process exit, SIGINT and SIGTERM. - Before spawning, the script fails if anything answers on the port. The base URL comes from astro's "Local http://localhost:<port>" line, and a port other than the requested one is an error. - The browser launch and sitemap read are inside the try, so a failure there still stops the preview. The script exits with its exit code once the report is written. Checked on Windows: `npm run build`, then `A11Y_URLS=/support/ npm run a11y` twice in a row. Each run exited in about 33s with no astro preview left behind; exit code 1 is from the page's 12 real color-contrast findings. With a server already on 4331, the audit fails in 2s. With the browser launch failing after the preview is up, it exits in 6s and leaves no preview behind. `npm run check` passes. The POSIX process-group path was not exercised.
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.
On Windows the audit wrote its report and then never exited, leaving orphaned
astro previewservers on 4331, 4332 and up.startPreview()spawned astro throughrun-command.ts, which goes through cmd.exe, and
child.kill()ended only the wrapper. Theastro grandchild survived and kept the piped stdout/stderr open, so node stayed alive. One
run sat "running" for three hours at under a second of CPU.
With an orphan on 4331,
astro previewquietly moved to the next free port. The scriptkept polling 4331 and audited the orphan's older build.
stop. On stop,
taskkill /T /Fon Windows and a process-group kill on POSIX (the childis spawned detached) take the whole tree. The pipes are then destroyed and the child
unref'd. The same kill runs on process exit, SIGINT and SIGTERM.
from astro's "Local http://localhost:" line, and a port other than the requested
one is an error.
the preview. The script exits with its exit code once the report is written.
Checked on Windows:
npm run build, thenA11Y_URLS=/support/ npm run a11ytwice in a row.Each run exited in about 33s with no astro preview left behind; exit code 1 is from the
page's 12 real color-contrast findings. With a server already on 4331, the audit fails in
2s. With the browser launch failing after the preview is up, it exits in 6s and leaves no
preview behind.
npm run checkpasses. The POSIX process-group path was not exercised.