@lvce-editor/test-with-playwright-worker 14.8.0 → 15.0.0

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.
Files changed (2) hide show
  1. package/dist/workerMain.js +18 -4
  2. package/package.json +2 -2
@@ -1067,6 +1067,11 @@ const lockedPorts = {
1067
1067
  // and a new young set for locked ports are created.
1068
1068
  const releaseOldLockedPortsIntervalMs = 1000 * 15;
1069
1069
 
1070
+ // Keep `reserve` deliberately process-wide by port number.
1071
+ // It is meant to avoid in-process races, not to model every possible
1072
+ // IPv4/IPv6 or host-specific bind combination.
1073
+ const reservedPorts = new Set();
1074
+
1070
1075
  // Lazily create timeout on first use
1071
1076
  let timeout;
1072
1077
  const getLocalHosts = () => {
@@ -1113,11 +1118,16 @@ const getAvailablePort = async (options, hosts) => {
1113
1118
  }
1114
1119
  return options.port;
1115
1120
  };
1121
+ const isLockedPort = port => lockedPorts.old.has(port) || lockedPorts.young.has(port) || reservedPorts.has(port);
1116
1122
  const portCheckSequence = function* (ports) {
1117
1123
  yield 0; // Fall back to 0 if anything else failed
1118
1124
  };
1119
1125
  async function getPorts(options) {
1120
1126
  let exclude = new Set();
1127
+ const {
1128
+ reserve,
1129
+ ...netOptions
1130
+ } = {};
1121
1131
  if (timeout === undefined) {
1122
1132
  timeout = setTimeout(() => {
1123
1133
  timeout = undefined;
@@ -1137,19 +1147,23 @@ async function getPorts(options) {
1137
1147
  continue;
1138
1148
  }
1139
1149
  let availablePort = await getAvailablePort({
1140
- ...options,
1150
+ ...netOptions,
1141
1151
  port
1142
1152
  }, hosts); // eslint-disable-line no-await-in-loop
1143
- while (lockedPorts.old.has(availablePort) || lockedPorts.young.has(availablePort)) {
1153
+ while (isLockedPort(availablePort)) {
1144
1154
  if (port !== 0) {
1145
1155
  throw new Locked(port);
1146
1156
  }
1147
1157
  availablePort = await getAvailablePort({
1148
- ...options,
1158
+ ...netOptions,
1149
1159
  port
1150
1160
  }, hosts); // eslint-disable-line no-await-in-loop
1151
1161
  }
1152
- lockedPorts.young.add(availablePort);
1162
+ if (reserve) {
1163
+ reservedPorts.add(availablePort);
1164
+ } else {
1165
+ lockedPorts.young.add(availablePort);
1166
+ }
1153
1167
  return availablePort;
1154
1168
  } catch (error) {
1155
1169
  if (!['EADDRINUSE', 'EACCES'].includes(error.code) && !(error instanceof Locked)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/test-with-playwright-worker",
3
- "version": "14.8.0",
3
+ "version": "15.0.0",
4
4
  "description": "Worker package for test-with-playwright",
5
5
  "repository": {
6
6
  "type": "git",
@@ -12,7 +12,7 @@
12
12
  "type": "module",
13
13
  "main": "dist/workerMain.js",
14
14
  "dependencies": {
15
- "@playwright/test": "1.58.2"
15
+ "@playwright/test": "1.59.0"
16
16
  },
17
17
  "engines": {
18
18
  "node": ">=24"