@lvce-editor/test-with-playwright-worker 14.8.0 → 15.1.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.
- package/dist/workerMain.js +24 -11
- package/package.json +2 -2
package/dist/workerMain.js
CHANGED
|
@@ -864,8 +864,6 @@ const isEnoentError = error => {
|
|
|
864
864
|
return error && error.code === ENOENT;
|
|
865
865
|
};
|
|
866
866
|
|
|
867
|
-
// @ts-ignore
|
|
868
|
-
|
|
869
867
|
/**
|
|
870
868
|
* @param {Dirent} dirent
|
|
871
869
|
*/
|
|
@@ -1026,7 +1024,7 @@ const runTests = async ({
|
|
|
1026
1024
|
test,
|
|
1027
1025
|
testSrc,
|
|
1028
1026
|
timeout,
|
|
1029
|
-
traceFocus
|
|
1027
|
+
traceFocus: traceFocus ?? false
|
|
1030
1028
|
});
|
|
1031
1029
|
await onResult(result);
|
|
1032
1030
|
// @ts-ignore
|
|
@@ -1067,6 +1065,11 @@ const lockedPorts = {
|
|
|
1067
1065
|
// and a new young set for locked ports are created.
|
|
1068
1066
|
const releaseOldLockedPortsIntervalMs = 1000 * 15;
|
|
1069
1067
|
|
|
1068
|
+
// Keep `reserve` deliberately process-wide by port number.
|
|
1069
|
+
// It is meant to avoid in-process races, not to model every possible
|
|
1070
|
+
// IPv4/IPv6 or host-specific bind combination.
|
|
1071
|
+
const reservedPorts = new Set();
|
|
1072
|
+
|
|
1070
1073
|
// Lazily create timeout on first use
|
|
1071
1074
|
let timeout;
|
|
1072
1075
|
const getLocalHosts = () => {
|
|
@@ -1113,11 +1116,16 @@ const getAvailablePort = async (options, hosts) => {
|
|
|
1113
1116
|
}
|
|
1114
1117
|
return options.port;
|
|
1115
1118
|
};
|
|
1119
|
+
const isLockedPort = port => lockedPorts.old.has(port) || lockedPorts.young.has(port) || reservedPorts.has(port);
|
|
1116
1120
|
const portCheckSequence = function* (ports) {
|
|
1117
1121
|
yield 0; // Fall back to 0 if anything else failed
|
|
1118
1122
|
};
|
|
1119
1123
|
async function getPorts(options) {
|
|
1120
1124
|
let exclude = new Set();
|
|
1125
|
+
const {
|
|
1126
|
+
reserve,
|
|
1127
|
+
...netOptions
|
|
1128
|
+
} = {};
|
|
1121
1129
|
if (timeout === undefined) {
|
|
1122
1130
|
timeout = setTimeout(() => {
|
|
1123
1131
|
timeout = undefined;
|
|
@@ -1137,19 +1145,23 @@ async function getPorts(options) {
|
|
|
1137
1145
|
continue;
|
|
1138
1146
|
}
|
|
1139
1147
|
let availablePort = await getAvailablePort({
|
|
1140
|
-
...
|
|
1148
|
+
...netOptions,
|
|
1141
1149
|
port
|
|
1142
1150
|
}, hosts); // eslint-disable-line no-await-in-loop
|
|
1143
|
-
while (
|
|
1151
|
+
while (isLockedPort(availablePort)) {
|
|
1144
1152
|
if (port !== 0) {
|
|
1145
1153
|
throw new Locked(port);
|
|
1146
1154
|
}
|
|
1147
1155
|
availablePort = await getAvailablePort({
|
|
1148
|
-
...
|
|
1156
|
+
...netOptions,
|
|
1149
1157
|
port
|
|
1150
1158
|
}, hosts); // eslint-disable-line no-await-in-loop
|
|
1151
1159
|
}
|
|
1152
|
-
|
|
1160
|
+
if (reserve) {
|
|
1161
|
+
reservedPorts.add(availablePort);
|
|
1162
|
+
} else {
|
|
1163
|
+
lockedPorts.young.add(availablePort);
|
|
1164
|
+
}
|
|
1153
1165
|
return availablePort;
|
|
1154
1166
|
} catch (error) {
|
|
1155
1167
|
if (!['EADDRINUSE', 'EACCES'].includes(error.code) && !(error instanceof Locked)) {
|
|
@@ -1165,8 +1177,7 @@ const getPort = () => {
|
|
|
1165
1177
|
return getPorts();
|
|
1166
1178
|
};
|
|
1167
1179
|
|
|
1168
|
-
const getPossibleServerPaths =
|
|
1169
|
-
const cwd = process.cwd();
|
|
1180
|
+
const getPossibleServerPaths = cwd => {
|
|
1170
1181
|
const toTry = ['@lvce-editor/server', pathToFileURL(join(cwd, '..', 'server', 'node_modules', '@lvce-editor', 'server', 'index.js')).toString(), pathToFileURL(join(cwd, '..', 'build', 'node_modules', '@lvce-editor', 'server', 'index.js')).toString(), pathToFileURL(join(cwd, '..', '..', '..', 'packages', 'server', 'node_modules', '@lvce-editor', 'server', 'index.js')).toString()];
|
|
1171
1182
|
return toTry;
|
|
1172
1183
|
};
|
|
@@ -1175,7 +1186,7 @@ const getServerPath = async serverPath => {
|
|
|
1175
1186
|
if (serverPath) {
|
|
1176
1187
|
return serverPath;
|
|
1177
1188
|
}
|
|
1178
|
-
const toTry = getPossibleServerPaths();
|
|
1189
|
+
const toTry = getPossibleServerPaths(process.cwd());
|
|
1179
1190
|
// @ts-ignore
|
|
1180
1191
|
for (const path of toTry) {
|
|
1181
1192
|
try {
|
|
@@ -1340,7 +1351,9 @@ const runAllTests = async (extensionPath, testPath, cwd, headless, timeout, serv
|
|
|
1340
1351
|
await rpc.invoke(HandleFinalResult, finalResult);
|
|
1341
1352
|
};
|
|
1342
1353
|
await runTests({
|
|
1343
|
-
filter
|
|
1354
|
+
...(filter ? {
|
|
1355
|
+
filter
|
|
1356
|
+
} : {}),
|
|
1344
1357
|
headless,
|
|
1345
1358
|
onFinalResult,
|
|
1346
1359
|
onResult,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lvce-editor/test-with-playwright-worker",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "15.1.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.
|
|
15
|
+
"@playwright/test": "1.59.0"
|
|
16
16
|
},
|
|
17
17
|
"engines": {
|
|
18
18
|
"node": ">=24"
|