@hughescr/stryker-bun-runner 1.3.6 → 1.3.8

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/README.md CHANGED
@@ -292,24 +292,43 @@ of them in a clean run's logs is worth investigating before trusting the score.
292
292
  apply to them.
293
293
 
294
294
  At the default (WARN) log level, dry runs also emit a few lines tracing this
295
- handshake: `Drain-request received`, `Drain handler settled via ...`, and
296
- `Post-drain inspector snapshot`, reporting the round-trip's outcome (`ack`,
297
- `silence`, `ceiling`, or `send-rejected`), the found/start/end event-count
298
- deltas observed during the wait, and any found-id gaps. A separate DEBUG-level
295
+ handshake: `Drain-request received`, `Drain handler settled via ...`,
296
+ `Post-drain inspector snapshot`, and `Post-drain inspector close/collision
297
+ diagnostics`, reporting the round-trip's outcome (`ack`, `silence`,
298
+ `ceiling`, or `send-rejected`), the found/start/end event-count deltas
299
+ observed during the wait, any found-id gaps, the WebSocket close
300
+ code/reason/wasClean (plus how many ms after the last received frame the
301
+ close arrived), and raw-vs-unique found-event counts. A separate DEBUG-level
299
302
  line notes if the inspector socket closed while the run was still thought to
300
- be in progress — this is logged at DEBUG rather than WARN because the child
301
- closing its own socket right after receiving `'drained'` routinely wins the
302
- race against the runner's own close-expectation on a clean run, so on its own
303
- it is not evidence of anything wrong (it is folded into the completeness
304
- gate's error message as corroborating context only if that gate has already
305
- fired for another reason). Together the WARN-level lines are useful for
306
- telling apart two different failure shapes: residual loss caused by a
307
- runner-side bound being hit (a give-up
308
- outcome — `silence` or `ceiling`) versus loss happening inside Bun's own
309
- inspector agent (found-id gaps persisting even though the round-trip `ack`
310
- succeeded). One caveat: gap detection assumes Bun assigns test-discovery ids
311
- densely, which has been observed but is not a guaranteed contract, so treat
312
- gap reports as diagnostic rather than definitive.
303
+ be in progress (including the same close code/reason/wasClean detail) — this
304
+ is logged at DEBUG rather than WARN because the child closing its own socket
305
+ right after receiving `'drained'` routinely wins the race against the
306
+ runner's own close-expectation on a clean run, so on its own it is not
307
+ evidence of anything wrong (it is folded into the completeness gate's error
308
+ message as corroborating context — now including the captured close
309
+ code/reason — only if that gate has already fired for another reason).
310
+ Together the WARN-level lines are useful for telling apart two different
311
+ failure shapes: residual loss caused by a runner-side bound being hit (a
312
+ give-up outcome — `silence` or `ceiling`) versus loss happening inside Bun's
313
+ own inspector agent (found-id gaps persisting even though the round-trip
314
+ `ack` succeeded). One caveat: gap detection assumes Bun assigns
315
+ test-discovery ids densely, which has been observed but is not a guaranteed
316
+ contract — and even a dense (0-gap) id range does **not** prove
317
+ losslessness: a confirmed Bun TestReporter id-collision bug (two interleaved
318
+ `1..N` id sequences when `TestReporter.enable` lands mid-collection) keeps
319
+ ids dense while silently merging two distinct tests under one shared id.
320
+ That is exactly what the close/collision diagnostics line's
321
+ raw/unique/duplicate found counts exist to catch: a **nonzero duplicate
322
+ count is direct in-the-wild evidence of that id-collision bug**, and the
323
+ close code/reason/wasClean fields confirm or rule out a separate confirmed
324
+ Bun bug where `idleTimeout: 0` websockets are force-closed on a ~252-second
325
+ ping cycle (`ERR_WEBSOCKET_TIMEOUT`) — an abnormal close landing right on
326
+ that cadence points at the ping-cycle bug, while a clean close rules it out.
327
+ Finally, a WARN-level `Inspector request unanswered after ...` line fires if
328
+ an inspector protocol request (e.g. `TestReporter.enable`) goes unanswered
329
+ for more than 2 seconds while other frames are still arriving on the same
330
+ connection — a protocol-level stall signature distinct from the
331
+ total-silence give-up above.
313
332
 
314
333
  ### Coverage-bleed warning (dry run only)
315
334
 
package/dist/index.d.ts CHANGED
@@ -359,10 +359,29 @@ export declare class BunTestRunner implements TestRunner {
359
359
  * 2. Base-name match in localBaseIndex (built from testFilter)
360
360
  * 3. Exact match in this.cachedTestNames (instance registry from dryRun)
361
361
  * 4. Base-name match in this.baseNameIndex (instance registry from dryRun)
362
- * 5. Raw name as-is with a warn log — last resort if nothing resolves.
362
+ *
363
+ * Names resolving through none of these are DROPPED with a single WARN — never
364
+ * emitted raw. Every entry in a Killed result's killedBy must be exactly a
365
+ * dry-run TestResult.id: Stryker core's remapTestId (`id => testIdMap.get(id)
366
+ * ?? id`) writes anything else verbatim into the incremental report, where it
367
+ * orphans against the test registry and the differ silently re-runs the mutant
368
+ * on every incremental pass, forever (and the next accumulation pass launders
369
+ * the orphan into an empty killedBy). Dropping instead degrades that one
370
+ * mutant to correct-but-non-reusable — same re-run cost, but loudly visible
371
+ * and never poisonous. No guessed recovery is attempted: bare console names
372
+ * can collide across files, and --test-name-pattern leakage (see mutantRun)
373
+ * means the killer may not even be a testFilter member, so any inference
374
+ * risks crediting the wrong test and enabling stale cache reuse.
363
375
  */
364
376
  private resolveKilledBy;
365
377
  /**
378
+ * WARN about failed test names that could not be resolved to dry-run test
379
+ * ids (and are therefore dropped from killedBy by resolveKilledBy). WARN,
380
+ * not debug — the old debug-level log is why the resulting cache poisoning
381
+ * was invisible in CI. No-op when everything resolved.
382
+ */
383
+ private warnUnresolvedKilledBy;
384
+ /**
366
385
  * Cleanup resources
367
386
  */
368
387
  dispose(): Promise<void>;
package/dist/index.js CHANGED
@@ -5972,6 +5972,8 @@ function isTestReporterEndEvent(message) {
5972
5972
  }
5973
5973
 
5974
5974
  // src/inspector/inspector-client.ts
5975
+ var REQUEST_STALL_WARN_MS = 2000;
5976
+
5975
5977
  class InspectorTimeoutError extends Error {
5976
5978
  constructor(message) {
5977
5979
  super(message);
@@ -6004,6 +6006,10 @@ class InspectorClient {
6004
6006
  foundCount = 0;
6005
6007
  startCount = 0;
6006
6008
  endCount = 0;
6009
+ closeCode = undefined;
6010
+ closeReason = undefined;
6011
+ closeWasClean = undefined;
6012
+ msFromLastFrameToClose = undefined;
6007
6013
  constructor(options) {
6008
6014
  this.handlers = options.handlers ?? {};
6009
6015
  this.WebSocketClass = options.WebSocketClass ?? wrapper_default;
@@ -6038,8 +6044,8 @@ class InspectorClient {
6038
6044
  this.handleError(error);
6039
6045
  reject(error);
6040
6046
  });
6041
- ws.addEventListener("close", () => {
6042
- this.handleClose();
6047
+ ws.addEventListener("close", (event) => {
6048
+ this.handleClose(event.code, event.reason, event.wasClean);
6043
6049
  });
6044
6050
  ws.addEventListener("message", (event) => {
6045
6051
  this.handleMessage(event.data);
@@ -6054,20 +6060,40 @@ class InspectorClient {
6054
6060
  const message = { id, method, params };
6055
6061
  return new Promise((resolve3, reject) => {
6056
6062
  const effectiveTimeoutMs = timeoutMs ?? this.state.requestTimeout;
6063
+ const stallTimer = this.handlers.onRequestStall ? setTimeout(() => {
6064
+ if (this.pendingRequests.has(id)) {
6065
+ const msSinceLastFrame = this.getMsSinceLastFrame();
6066
+ if (msSinceLastFrame < REQUEST_STALL_WARN_MS) {
6067
+ this.handlers.onRequestStall({ method, id, msUnanswered: REQUEST_STALL_WARN_MS, msSinceLastFrame });
6068
+ }
6069
+ }
6070
+ }, REQUEST_STALL_WARN_MS) : undefined;
6057
6071
  const timer = setTimeout(() => {
6058
6072
  this.pendingRequests.delete(id);
6073
+ if (stallTimer) {
6074
+ clearTimeout(stallTimer);
6075
+ }
6059
6076
  reject(new InspectorTimeoutError(`Request timeout after ${effectiveTimeoutMs}ms: ${method}`));
6060
6077
  }, effectiveTimeoutMs);
6061
- this.pendingRequests.set(id, { resolve: resolve3, reject, timer });
6078
+ this.pendingRequests.set(id, { resolve: resolve3, reject, timer, stallTimer });
6062
6079
  try {
6063
6080
  this.ws.send(JSON.stringify(message));
6064
6081
  } catch (error) {
6065
6082
  this.pendingRequests.delete(id);
6066
6083
  clearTimeout(timer);
6084
+ if (stallTimer) {
6085
+ clearTimeout(stallTimer);
6086
+ }
6067
6087
  reject(error instanceof Error ? error : new Error(String(error)));
6068
6088
  }
6069
6089
  });
6070
6090
  }
6091
+ clearPendingTimers(pending) {
6092
+ clearTimeout(pending.timer);
6093
+ if (pending.stallTimer) {
6094
+ clearTimeout(pending.stallTimer);
6095
+ }
6096
+ }
6071
6097
  async close() {
6072
6098
  if (this.isClosing || !this.ws) {
6073
6099
  return;
@@ -6075,7 +6101,7 @@ class InspectorClient {
6075
6101
  this.isClosing = true;
6076
6102
  const error = new InspectorConnectionError("Connection closed");
6077
6103
  for (const pending of this.pendingRequests.values()) {
6078
- clearTimeout(pending.timer);
6104
+ this.clearPendingTimers(pending);
6079
6105
  pending.reject(error);
6080
6106
  }
6081
6107
  this.pendingRequests.clear();
@@ -6130,6 +6156,22 @@ class InspectorClient {
6130
6156
  getEventCounts() {
6131
6157
  return { found: this.foundCount, start: this.startCount, end: this.endCount };
6132
6158
  }
6159
+ getCloseInfo() {
6160
+ return {
6161
+ code: this.closeCode,
6162
+ reason: this.closeReason,
6163
+ wasClean: this.closeWasClean,
6164
+ msFromLastFrameToClose: this.msFromLastFrameToClose
6165
+ };
6166
+ }
6167
+ getFoundIdCollisionStats() {
6168
+ const uniqueFoundIdCount = this.testHierarchy.size;
6169
+ return {
6170
+ rawFoundCount: this.foundCount,
6171
+ uniqueFoundIdCount,
6172
+ duplicateFoundIdCount: this.foundCount - uniqueFoundIdCount
6173
+ };
6174
+ }
6133
6175
  getFoundIdGaps() {
6134
6176
  if (this.testHierarchy.size === 0) {
6135
6177
  return [];
@@ -6160,7 +6202,7 @@ class InspectorClient {
6160
6202
  const pending = this.pendingRequests.get(message.id);
6161
6203
  if (pending) {
6162
6204
  this.pendingRequests.delete(message.id);
6163
- clearTimeout(pending.timer);
6205
+ this.clearPendingTimers(pending);
6164
6206
  if (message.error) {
6165
6207
  pending.reject(new Error(`Inspector error: ${message.error.message}`));
6166
6208
  } else {
@@ -6250,8 +6292,12 @@ class InspectorClient {
6250
6292
  }
6251
6293
  return { fullName: parts.join(" > "), bunName: parts.join(" ") };
6252
6294
  }
6253
- handleClose() {
6295
+ handleClose(code, reason, wasClean) {
6254
6296
  this.wsClosed = true;
6297
+ this.closeCode = code;
6298
+ this.closeReason = reason;
6299
+ this.closeWasClean = wasClean;
6300
+ this.msFromLastFrameToClose = Date.now() - this.lastFrameReceivedAt;
6255
6301
  const waiters = this.closeWaiters;
6256
6302
  this.closeWaiters = [];
6257
6303
  for (const finish of waiters) {
@@ -6262,11 +6308,19 @@ class InspectorClient {
6262
6308
  }
6263
6309
  this._wasClosedUnexpectedly = true;
6264
6310
  if (this.handlers.onUnexpectedClose) {
6265
- this.handlers.onUnexpectedClose({ wsClosed: this.wsClosed, closeExpected: this.closeExpected, isClosing: this.isClosing });
6311
+ this.handlers.onUnexpectedClose({
6312
+ wsClosed: this.wsClosed,
6313
+ closeExpected: this.closeExpected,
6314
+ isClosing: this.isClosing,
6315
+ closeCode: this.closeCode,
6316
+ closeReason: this.closeReason,
6317
+ closeWasClean: this.closeWasClean,
6318
+ msFromLastFrameToClose: this.msFromLastFrameToClose
6319
+ });
6266
6320
  }
6267
6321
  const error = new InspectorConnectionError("Connection closed unexpectedly");
6268
6322
  for (const pending of this.pendingRequests.values()) {
6269
- clearTimeout(pending.timer);
6323
+ this.clearPendingTimers(pending);
6270
6324
  pending.reject(error);
6271
6325
  }
6272
6326
  this.pendingRequests.clear();
@@ -6278,11 +6332,55 @@ class InspectorClient {
6278
6332
  }
6279
6333
  }
6280
6334
  }
6335
+ // src/utils/test-name-pattern.ts
6336
+ var MAX_TEST_NAME_PATTERN_LENGTH = 1e5;
6337
+ var TEST_FILE_EXT_PATTERN = String.raw`(?:test|spec)\.(?:[jt]sx?|[mc][jt]s)`;
6338
+ var fileExtRe = new RegExp(String.raw`\.${TEST_FILE_EXT_PATTERN}$`);
6339
+ var dedupSuffixRe = / \[\d+\]$/;
6340
+ var metaRe = /[.*+?^${}()|[\]\\/]/g;
6341
+ function escapeRegex(str) {
6342
+ return str.replaceAll(metaRe, String.raw`\$&`);
6343
+ }
6344
+ function buildTestNamePattern(testFilter, testNameIndex) {
6345
+ if (testFilter.length === 0) {
6346
+ return;
6347
+ }
6348
+ const alternatives = new Set;
6349
+ for (const id of testFilter) {
6350
+ const exact = testNameIndex?.get(id);
6351
+ if (exact !== undefined && exact.length > 0 && !exact.includes("\x00")) {
6352
+ alternatives.add(escapeRegex(exact));
6353
+ continue;
6354
+ }
6355
+ const firstSepIdx = id.indexOf(" > ");
6356
+ let name = firstSepIdx !== -1 && fileExtRe.test(id.slice(0, firstSepIdx)) ? id.slice(firstSepIdx + 3) : id;
6357
+ name = name.replace(dedupSuffixRe, "");
6358
+ name = name.replaceAll(" > ", " ");
6359
+ name = escapeRegex(name);
6360
+ if (name.length > 0) {
6361
+ alternatives.add(name);
6362
+ }
6363
+ }
6364
+ if (alternatives.size === 0) {
6365
+ return;
6366
+ }
6367
+ const pattern = `^(?:${[...alternatives].join("|")})$`;
6368
+ if (Buffer.byteLength(pattern) > MAX_TEST_NAME_PATTERN_LENGTH) {
6369
+ return;
6370
+ }
6371
+ return pattern;
6372
+ }
6373
+
6281
6374
  // src/parsers/console-parser.ts
6375
+ var fileHeaderRe = new RegExp(String.raw`^(?:::group::)?([^:]+\.${TEST_FILE_EXT_PATTERN}):$`);
6376
+ var workflowCommandRe = /^::(?:group|endgroup|error|warning|notice|debug|add-mask|add-matcher|remove-matcher)(?:::|\s|$)/;
6282
6377
  function parseFilePath(line) {
6283
- const fileMatch = /^([\w./-]+\.(?:test|spec)\.(?:ts|tsx|js|jsx|mts|mjs)):$/.exec(line);
6378
+ const fileMatch = fileHeaderRe.exec(line);
6284
6379
  return fileMatch ? fileMatch[1] : null;
6285
6380
  }
6381
+ function isWorkflowCommandLine(line) {
6382
+ return workflowCommandRe.test(line);
6383
+ }
6286
6384
  function buildTestName(testName, currentFile) {
6287
6385
  return currentFile ? `${currentFile} > ${testName}` : testName;
6288
6386
  }
@@ -6405,6 +6503,9 @@ ${stderr}`;
6405
6503
  currentFile = filePath;
6406
6504
  continue;
6407
6505
  }
6506
+ if (isWorkflowCommandLine(line)) {
6507
+ continue;
6508
+ }
6408
6509
  const parseResult = parseTestLine(line, currentFile);
6409
6510
  if (parseResult.test) {
6410
6511
  if (currentTest && collectingError) {
@@ -6420,9 +6521,7 @@ ${stderr}`;
6420
6521
  errorLines.push(line);
6421
6522
  }
6422
6523
  }
6423
- if (currentTest && collectingError) {
6424
- finalizeErrorMessage(currentTest, errorLines);
6425
- }
6524
+ finalizeErrorMessage(currentTest, errorLines);
6426
6525
  const summaryCounts = parseSummaryLines(output);
6427
6526
  counters.passed = Math.max(counters.passed, summaryCounts.passed);
6428
6527
  counters.failed = Math.max(counters.failed, summaryCounts.failed);
@@ -7962,43 +8061,6 @@ async function cleanupSanitizedBunfig(filePath) {
7962
8061
  }
7963
8062
  }
7964
8063
  }
7965
- // src/utils/test-name-pattern.ts
7966
- var MAX_TEST_NAME_PATTERN_LENGTH = 1e5;
7967
- var fileExtRe = /\.(?:test|spec)\.(?:[jt]sx?|m[jt]s)$/;
7968
- var dedupSuffixRe = / \[\d+\]$/;
7969
- var metaRe = /[.*+?^${}()|[\]\\/]/g;
7970
- function escapeRegex(str) {
7971
- return str.replaceAll(metaRe, String.raw`\$&`);
7972
- }
7973
- function buildTestNamePattern(testFilter, testNameIndex) {
7974
- if (testFilter.length === 0) {
7975
- return;
7976
- }
7977
- const alternatives = new Set;
7978
- for (const id of testFilter) {
7979
- const exact = testNameIndex?.get(id);
7980
- if (exact !== undefined && exact.length > 0 && !exact.includes("\x00")) {
7981
- alternatives.add(escapeRegex(exact));
7982
- continue;
7983
- }
7984
- const firstSepIdx = id.indexOf(" > ");
7985
- let name = firstSepIdx !== -1 && fileExtRe.test(id.slice(0, firstSepIdx)) ? id.slice(firstSepIdx + 3) : id;
7986
- name = name.replace(dedupSuffixRe, "");
7987
- name = name.replaceAll(" > ", " ");
7988
- name = escapeRegex(name);
7989
- if (name.length > 0) {
7990
- alternatives.add(name);
7991
- }
7992
- }
7993
- if (alternatives.size === 0) {
7994
- return;
7995
- }
7996
- const pattern = `^(?:${[...alternatives].join("|")})$`;
7997
- if (Buffer.byteLength(pattern) > MAX_TEST_NAME_PATTERN_LENGTH) {
7998
- return;
7999
- }
8000
- return pattern;
8001
- }
8002
8064
  // src/utils/test-file-discovery.ts
8003
8065
  import * as fsPromises from "node:fs/promises";
8004
8066
  import path3 from "node:path";
@@ -8535,7 +8597,10 @@ exit=%s timedOut=%s
8535
8597
  this.logger.warn("Inspector error: %s", error.message);
8536
8598
  },
8537
8599
  onUnexpectedClose: (context) => {
8538
- this.logger.debug("Inspector WebSocket closed while the run was still thought to be in progress (wsClosed=%s closeExpected=%s isClosing=%s) — often benign; see checkCompletenessGate", context.wsClosed, context.closeExpected, context.isClosing);
8600
+ this.logger.debug("Inspector WebSocket closed while the run was still thought to be in progress (wsClosed=%s closeExpected=%s isClosing=%s closeCode=%s closeReason=%s closeWasClean=%s msFromLastFrameToClose=%s) — often benign; see checkCompletenessGate", context.wsClosed, context.closeExpected, context.isClosing, String(context.closeCode), String(context.closeReason), String(context.closeWasClean), String(context.msFromLastFrameToClose));
8601
+ },
8602
+ onRequestStall: (info) => {
8603
+ this.logger.warn("Inspector request unanswered after %dms even though other frames are still arriving (last frame %dms ago): %s (id=%d) — possible protocol-level stall distinct from total silence", info.msUnanswered, info.msSinceLastFrame, info.method, info.id);
8539
8604
  }
8540
8605
  }
8541
8606
  });
@@ -8592,12 +8657,15 @@ exit=%s timedOut=%s
8592
8657
  this.logger.debug("Inspector collected %d tests in hierarchy, %d in execution order", testHierarchy.length, executionOrder.length);
8593
8658
  const finalGaps = inspector.getFoundIdGaps();
8594
8659
  this.logger.warn("Post-drain inspector snapshot: %d found-id gap(s) remaining%s; drain handshake %s", finalGaps.length, formatGapIdList(finalGaps), formatDrainSettleReason(drainSettleReason));
8660
+ const closeInfo = inspector.getCloseInfo();
8661
+ const collisionStats = inspector.getFoundIdCollisionStats();
8662
+ this.logger.warn("Post-drain inspector close/collision diagnostics: WS close code=%s reason=%s wasClean=%s msFromLastFrameToClose=%s; " + "found events %d raw / %d unique id(s) / %d duplicate id event(s) (nonzero duplicates = direct evidence of the Bun " + "TestReporter id-collision bug; the found-id-gap count above is density-only — it does NOT prove losslessness under collisions)", String(closeInfo.code), String(closeInfo.reason), String(closeInfo.wasClean), String(closeInfo.msFromLastFrameToClose), collisionStats.rawFoundCount, collisionStats.uniqueFoundIdCount, collisionStats.duplicateFoundIdCount);
8595
8663
  const parsed = parseBunTestOutput(result.stdout, result.stderr);
8596
8664
  const earlyResult = this.checkDryRunProcessResult(result, parsed, testHierarchy);
8597
8665
  if (earlyResult) {
8598
8666
  return earlyResult;
8599
8667
  }
8600
- return await this.buildGatedDryRunResult(result, parsed, testHierarchy, executionOrder, totalElapsedMs, wasClosedUnexpectedly);
8668
+ return await this.buildGatedDryRunResult(result, parsed, testHierarchy, executionOrder, totalElapsedMs, wasClosedUnexpectedly, closeInfo);
8601
8669
  } finally {
8602
8670
  abortController.abort();
8603
8671
  if (this.currentAbortController === abortController) {
@@ -8606,11 +8674,11 @@ exit=%s timedOut=%s
8606
8674
  await syncServer.close();
8607
8675
  }
8608
8676
  }
8609
- async buildGatedDryRunResult(result, parsed, testHierarchy, executionOrder, totalElapsedMs, wasClosedUnexpectedly) {
8677
+ async buildGatedDryRunResult(result, parsed, testHierarchy, executionOrder, totalElapsedMs, wasClosedUnexpectedly, closeInfo) {
8610
8678
  const { coverage: mutantCoverage, inspectorIdToProjectFile, rawKeyCount, orphanedKeyCount } = await this.collectAndRemapCoverage(testHierarchy, executionOrder);
8611
8679
  const { tests, testNameIndex } = this.buildTestsFromInspector(testHierarchy, executionOrder, parsed, totalElapsedMs, inspectorIdToProjectFile);
8612
8680
  tests.sort((a, b) => a.name.localeCompare(b.name));
8613
- const gateResult = this.checkCompletenessGate(executionOrder, testHierarchy, parsed, rawKeyCount, orphanedKeyCount, wasClosedUnexpectedly, tests);
8681
+ const gateResult = this.checkCompletenessGate(executionOrder, testHierarchy, parsed, rawKeyCount, orphanedKeyCount, wasClosedUnexpectedly, tests, closeInfo);
8614
8682
  if (gateResult) {
8615
8683
  return gateResult;
8616
8684
  }
@@ -8761,13 +8829,12 @@ exit=%s timedOut=%s
8761
8829
  }
8762
8830
  const killedBy = this.resolveKilledBy(rawFailedNames, localRegistry, localBaseIndex, mutantId);
8763
8831
  if (killedBy.length === 0) {
8764
- this.logger.warn("No failed tests identified for mutant %s — Bun output could not be parsed; " + `using "unknown" fallback (breaks incremental cache)
8832
+ this.logger.warn("Mutant %s: no killing test identifiable — emitting empty killedBy; " + `this mutant will re-run on every incremental run
8765
8833
  ` + `exit=%s
8766
8834
  --- STDOUT (first 600 chars) ---
8767
8835
  %s
8768
8836
  ` + `--- STDERR (first 600 chars) ---
8769
8837
  %s`, mutantId, String(result.exitCode), result.stdout.slice(0, 600) || "(empty)", result.stderr.slice(0, 600) || "(empty)");
8770
- killedBy.push("unknown");
8771
8838
  }
8772
8839
  return {
8773
8840
  status: MutantRunStatus.Killed,
@@ -8849,7 +8916,7 @@ ${lines.join(`
8849
8916
  %s`, String(result.exitCode), parsed.failed, result.stderr.slice(-500));
8850
8917
  }
8851
8918
  }
8852
- checkCompletenessGate(executionOrder, testHierarchy, parsed, rawKeyCount, orphanedKeyCount, wasClosedUnexpectedly, tests) {
8919
+ checkCompletenessGate(executionOrder, testHierarchy, parsed, rawKeyCount, orphanedKeyCount, wasClosedUnexpectedly, tests, closeInfo) {
8853
8920
  if (tests.some((t) => t.status === TestStatus.Failed)) {
8854
8921
  return null;
8855
8922
  }
@@ -8873,7 +8940,8 @@ ${lines.join(`
8873
8940
  reasons.push(`${orphanedKeyCount} of ${rawKeyCount} coverage key(s) could not be paired with any inspector test (orphaned)`);
8874
8941
  }
8875
8942
  if (wasClosedUnexpectedly) {
8876
- reasons.push("the inspector WebSocket closed unexpectedly before this data could be fully drained");
8943
+ const closeDetail = closeInfo.code === undefined ? "close code/reason not captured" : `close code=${closeInfo.code} reason=${JSON.stringify(closeInfo.reason ?? "")} wasClean=${String(closeInfo.wasClean)}, ${String(closeInfo.msFromLastFrameToClose)}ms after the last received frame`;
8944
+ reasons.push(`the inspector WebSocket closed unexpectedly before this data could be fully drained (${closeDetail})`);
8877
8945
  }
8878
8946
  const errorMessage = "stryker-bun-runner: dry run data-completeness check failed — " + `${reasons.join("; ")}. This indicates the Bun inspector event stream may have been ` + "truncated mid-run; proceeding would risk silently " + "corrupted coverage attribution, so this dry run is being reported as an error instead of " + "Complete, and the test registry has NOT been persisted.";
8879
8947
  this.logger.error("%s", errorMessage);
@@ -8932,6 +9000,7 @@ ${lines.join(`
8932
9000
  }
8933
9001
  resolveKilledBy(rawFailedNames, localRegistry, localBaseIndex, mutantId) {
8934
9002
  const killedBySet = new Set;
9003
+ const unresolved = new Set;
8935
9004
  for (const name of rawFailedNames) {
8936
9005
  if (localRegistry.has(name)) {
8937
9006
  killedBySet.add(name);
@@ -8957,11 +9026,18 @@ ${lines.join(`
8957
9026
  }
8958
9027
  continue;
8959
9028
  }
8960
- this.logger.debug('killedBy name "%s" for mutant %s not found in test registry; including as-is', name, mutantId);
8961
- killedBySet.add(name);
9029
+ unresolved.add(name);
8962
9030
  }
9031
+ this.warnUnresolvedKilledBy(unresolved, mutantId);
8963
9032
  return [...killedBySet];
8964
9033
  }
9034
+ warnUnresolvedKilledBy(unresolved, mutantId) {
9035
+ if (unresolved.size === 0) {
9036
+ return;
9037
+ }
9038
+ const sample = [...unresolved];
9039
+ this.logger.warn("Mutant %s: %d failed test name(s) could not be resolved to dry-run test ids and will not be recorded in killedBy — this mutant's Killed verdict will not be reusable from the incremental cache: %s%s", mutantId, unresolved.size, sample.slice(0, 5).join(", "), sample.length > 5 ? ", …" : "");
9040
+ }
8965
9041
  async dispose() {
8966
9042
  this.logger.debug("Disposing BunTestRunner");
8967
9043
  if (this.currentAbortController) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hughescr/stryker-bun-runner",
3
- "version": "1.3.6",
3
+ "version": "1.3.8",
4
4
  "description": "Stryker test runner plugin for Bun with perTest coverage support",
5
5
  "keywords": [
6
6
  "stryker",