@josueavalosjim/taste-check 0.5.0 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@josueavalosjim/taste-check",
3
- "version": "0.5.0",
3
+ "version": "0.5.1",
4
4
  "description": "Design review in CI with a line down the middle: measured checks that gate the build (WCAG contrast from your tokens or from a real rendered page, one-off values in your markup) and a fresh-eyes model judge whose verdicts stay advisory. Zero dependencies. Ships no design rules of its own.",
5
5
  "keywords": [
6
6
  "accessibility",
package/src/cdp.mjs CHANGED
@@ -224,11 +224,18 @@ export async function connect({ endpoint, browserPath, timeout = 15000 }) {
224
224
  return result.value;
225
225
  },
226
226
  /**
227
- * Best effort, and deliberately incapable of throwing. Teardown failing
228
- * must never take down a run whose measurements already succeeded, and a
229
- * temp directory the browser is still writing into is not worth a crash.
227
+ * Waits for the browser to actually exit before removing its profile.
228
+ *
229
+ * Killing and deleting in the same breath loses a race with Chrome, which
230
+ * is still flushing its profile when the signal arrives. Best effort was
231
+ * not good enough: it left a directory behind on nearly every run, and a
232
+ * tool that litters the temp directory every time CI runs is not one to
233
+ * inflict on anybody.
234
+ *
235
+ * Still incapable of throwing. Teardown must never take down a run whose
236
+ * measurements already succeeded.
230
237
  */
231
- close() {
238
+ async close() {
232
239
  try {
233
240
  ws.close();
234
241
  } catch {
@@ -236,7 +243,20 @@ export async function connect({ endpoint, browserPath, timeout = 15000 }) {
236
243
  }
237
244
  if (!child) return;
238
245
  try {
239
- child.kill();
246
+ if (child.exitCode === null && child.signalCode === null) {
247
+ const exited = new Promise((resolve) => child.once('exit', resolve));
248
+ child.kill();
249
+ // SIGTERM is usually enough. If it is not, stop being polite.
250
+ const forced = new Promise((resolve) => setTimeout(resolve, 2000)).then(() => {
251
+ try {
252
+ child.kill('SIGKILL');
253
+ } catch {
254
+ /* already gone */
255
+ }
256
+ return new Promise((resolve) => setTimeout(resolve, 300));
257
+ });
258
+ await Promise.race([exited, forced]);
259
+ }
240
260
  } catch {
241
261
  /* already gone */
242
262
  }
package/src/runtime.mjs CHANGED
@@ -147,7 +147,7 @@ export async function runRuntime(config, cwd, { connect: open = connect } = {})
147
147
  } catch (error) {
148
148
  problems.push(`the page could not be measured: ${error.message}`);
149
149
  } finally {
150
- page.close();
150
+ await page.close();
151
151
  }
152
152
 
153
153
  return {