laywill / laywill/laywill.github.io
refactor: share one headless-Chrome helper between check-render and build-og-card
Nobody has claimed this yet.
- Dominant language
- HTML
- Stars
- 0
- Forks
- 0
- Avg merge
- 8h 17m
- Merged PRs (30d)
- 58
Description
Branch off master and PR into master, not main. This is the v1 site.
scripts/build-og-card.mjs (#130) needs headless Chrome for exactly the same reasons scripts/check-render.mjs does, and it now carries its own copy of the same four pieces of plumbing:
findChrome()— theCHROME_PATHoverride and the per-platform install locationslaunchChrome()— the flag set, and scraping the DevTools URL out of stderrstopChrome()— waiting for the exit rather than the signal, because Windows keeps the user-data-dir locked until Chrome has goneconnect()/withTimeout()— the minimal CDP client over one browser-level socket
The card builder's copy is the smaller of the two: it drives one page, so it drops the event waitFor and the per-target session bookkeeping check-render needs. Nothing about the Chrome handling itself differs.
This is the shape #162 was about. There, check-canonicals and check-render had a static.yml allowlist parser each, and they had already drifted in a way that mattered: the render check read only the first cp ... _site/, so a page added in a later cp deployed but was never rendered. One parser in scripts/static-allowlist.mjs fixed it. The same argument applies here before these two copies drift — a fix to Chrome discovery, or a new flag needed for a future Chrome, currently has to be made twice, and only one of the two runs in CI, so the other can rot unnoticed.
Not urgent: the copies are identical today, and build-og-card.mjs is a manual tool run rarely rather than a check. Filed so it is a decision rather than an accident.
Proposal
Extract the shared parts into scripts/chrome.mjs, alongside scripts/static-allowlist.mjs, and have both scripts import it. check-render.mjs keeps whatever is genuinely specific to rendering every page (the viewport list, the is-loading and image-ratio measurement, the page loop).
Worth deciding as part of it: whether PAGE_TIMEOUT_MS belongs to the module or stays per-caller, since the two have no reason to agree.
Acceptance criteria
- One copy of Chrome discovery, launch, shutdown and the CDP client
-
npm run check-renderbehaves identically — same failures on a broken image, a distorted aspect ratio and a stuckis-loading -
npm run og-cardstill produces a byte-comparable card - Neither script reaches into the other
Refs #130, #162
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Read scripts/check-render.mjs and scripts/build-og-card.mjs, then compare their Chrome discovery, launch, shutdown, and CDP client code. Extract the shared parts into scripts/chrome.mjs while leaving rendering-specific behavior and the callers' PAGE_TIMEOUT_MS decisions in place. Run npm run check-render and npm run og-card; done means the render failures remain identical and the card remains byte-comparable.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js
- Domain
- tooling
- Issue type
- Refactor
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 72/100