refactor: share one headless-Chrome helper between check-render and build-og-card
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 72/100
- Tipo di issue
- Refactoring
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- javascript, node.js
- Ambito
- tooling
Direzione di ricerca
Leggi scripts/check-render.mjs e scripts/build-og-card.mjs, quindi confronta il codice relativo all'individuazione, all'avvio, all'arresto di Chrome e al client CDP. Estrai le parti condivise in scripts/chrome.mjs, lasciando al loro posto il comportamento specifico del rendering e le decisioni dei chiamanti relative a PAGE_TIMEOUT_MS. Esegui npm run check-render e npm run og-card; il lavoro è completato quando i fallimenti del rendering rimangono identici e la card continua a essere confrontabile a livello di byte.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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
- Lingua principale
- HTML
- Stelle
- 0
- Fork
- 0
- Merge medio
- 9h 52m
- PR unite (30g)
- 59
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di laywill/laywill.github.io
-
design
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
laywill/laywill.github.io#186 ·
-
design
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
laywill/laywill.github.io#183 · 1 commento ·
-
Difficoltà 2/5 Mezza giornata Idoneità per principianti 74/100
laywill/laywill.github.io#135 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
laywill/laywill.github.io#106 ·
-
infra needs-william
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
laywill/laywill.github.io#35 · 1 commento ·
Tutte le issue di laywill/laywill.github.io
Issue simili
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
stephrobert/dsoxlab#238 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
sublimehq/package_control#1780 ·
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
typelevel/sbt-typelevel#929 ·
-
Update HugeIcons library Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
antfu-collective/icones#398 ·