@hughescr/stryker-bun-runner 1.2.0 → 1.2.2

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.
@@ -81,39 +81,23 @@ function extractFilePrefix(bunMain: string): string {
81
81
 
82
82
  if(syncPort && shouldCollectCoverage) {
83
83
  try {
84
- ws = new WebSocket(`ws://localhost:${syncPort}/sync`);
85
-
86
- ws.onmessage = (_event) => {
87
- // Messages from the sync server are only 'ready' signals.
88
- // No per-test relay needed — coverage keys are file-prefixed counters.
89
- };
90
-
91
- // Wait for ready signal
84
+ // Install the real 'ready' handler before yielding to the event loop so
85
+ // there is no window where an arriving message is silently dropped.
92
86
  await new Promise<void>((resolve) => {
87
+ ws = new WebSocket(`ws://localhost:${syncPort}/sync`);
93
88
  const timeout = setTimeout(() => {
94
89
  console.warn('[Stryker] Timeout waiting for ready signal');
95
90
  resolve();
96
- }, 5000);
97
-
98
- const wsInstance = ws;
99
- if(!wsInstance) {
100
- clearTimeout(timeout);
101
- resolve();
102
- return;
103
- }
91
+ }, 2000);
104
92
 
105
- const originalOnMessage = wsInstance.onmessage;
106
- wsInstance.onmessage = (event) => {
93
+ ws.onmessage = (event) => {
107
94
  if(event.data === 'ready') {
108
95
  clearTimeout(timeout);
109
96
  resolve();
110
97
  }
111
- if(originalOnMessage) {
112
- originalOnMessage.call(wsInstance, event);
113
- }
114
98
  };
115
99
 
116
- wsInstance.onerror = () => {
100
+ ws.onerror = () => {
117
101
  clearTimeout(timeout);
118
102
  console.warn('[Stryker] Failed to connect to sync server');
119
103
  resolve();
@@ -125,23 +109,25 @@ if(syncPort && shouldCollectCoverage) {
125
109
  } else if(syncPort && !shouldCollectCoverage) {
126
110
  // No coverage collection, just wait for ready signal
127
111
  try {
128
- const ws = new WebSocket(`ws://localhost:${syncPort}/sync`);
112
+ // Install the real 'ready' handler before yielding to the event loop so
113
+ // there is no window where an arriving message is silently dropped.
129
114
  await new Promise<void>((resolve) => {
115
+ const wsLocal = new WebSocket(`ws://localhost:${syncPort}/sync`);
130
116
  const timeout = setTimeout(() => {
131
- ws.close();
117
+ wsLocal.close();
132
118
  console.warn('[Stryker Sync] Timeout waiting for ready signal, proceeding anyway');
133
119
  resolve();
134
- }, 5000);
120
+ }, 2000);
135
121
 
136
- ws.onmessage = (event) => {
122
+ wsLocal.onmessage = (event) => {
137
123
  if(event.data === 'ready') {
138
124
  clearTimeout(timeout);
139
- ws.close();
125
+ wsLocal.close();
140
126
  resolve();
141
127
  }
142
128
  };
143
129
 
144
- ws.onerror = () => {
130
+ wsLocal.onerror = () => {
145
131
  clearTimeout(timeout);
146
132
  console.warn('[Stryker Sync] Failed to connect to sync server, proceeding anyway');
147
133
  resolve();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hughescr/stryker-bun-runner",
3
- "version": "1.2.0",
3
+ "version": "1.2.2",
4
4
  "description": "Stryker test runner plugin for Bun with perTest coverage support",
5
5
  "keywords": [
6
6
  "stryker",
@@ -19,6 +19,7 @@
19
19
  },
20
20
  "license": "Apache-2.0",
21
21
  "author": "hughescr",
22
+ "sideEffects": false,
22
23
  "type": "module",
23
24
  "exports": {
24
25
  ".": {
@@ -57,6 +58,8 @@
57
58
  "eslint": "10.2.1",
58
59
  "eslint-formatter-overview": "2.0.0",
59
60
  "eslint-formatter-unix": "9.0.1",
61
+ "eslint-plugin-import-x": "4.16.2",
62
+ "eslint-plugin-n": "17.24.0",
60
63
  "typescript": "6.0.3"
61
64
  },
62
65
  "peerDependencies": {