@micromag/recorder 0.4.60 → 0.4.63
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/bin/recorder.js +17 -4
- package/package.json +3 -3
package/bin/recorder.js
CHANGED
|
@@ -24,6 +24,11 @@ const lockedPorts = {
|
|
|
24
24
|
// and a new young set for locked ports are created.
|
|
25
25
|
const releaseOldLockedPortsIntervalMs = 1000 * 15;
|
|
26
26
|
|
|
27
|
+
// Keep `reserve` deliberately process-wide by port number.
|
|
28
|
+
// It is meant to avoid in-process races, not to model every possible
|
|
29
|
+
// IPv4/IPv6 or host-specific bind combination.
|
|
30
|
+
const reservedPorts = new Set();
|
|
31
|
+
|
|
27
32
|
// Lazily create timeout on first use
|
|
28
33
|
let timeout;
|
|
29
34
|
|
|
@@ -75,6 +80,8 @@ const getAvailablePort = async (options, hosts) => {
|
|
|
75
80
|
return options.port;
|
|
76
81
|
};
|
|
77
82
|
|
|
83
|
+
const isLockedPort = port => lockedPorts.old.has(port) || lockedPorts.young.has(port) || reservedPorts.has(port);
|
|
84
|
+
|
|
78
85
|
const portCheckSequence = function * (ports) {
|
|
79
86
|
if (ports) {
|
|
80
87
|
yield * ports;
|
|
@@ -113,6 +120,8 @@ async function getPorts(options) {
|
|
|
113
120
|
}
|
|
114
121
|
}
|
|
115
122
|
|
|
123
|
+
const {reserve, ...netOptions} = options ?? {};
|
|
124
|
+
|
|
116
125
|
if (timeout === undefined) {
|
|
117
126
|
timeout = setTimeout(() => {
|
|
118
127
|
timeout = undefined;
|
|
@@ -135,16 +144,20 @@ async function getPorts(options) {
|
|
|
135
144
|
continue;
|
|
136
145
|
}
|
|
137
146
|
|
|
138
|
-
let availablePort = await getAvailablePort({...
|
|
139
|
-
while (
|
|
147
|
+
let availablePort = await getAvailablePort({...netOptions, port}, hosts); // eslint-disable-line no-await-in-loop
|
|
148
|
+
while (isLockedPort(availablePort)) {
|
|
140
149
|
if (port !== 0) {
|
|
141
150
|
throw new Locked(port);
|
|
142
151
|
}
|
|
143
152
|
|
|
144
|
-
availablePort = await getAvailablePort({...
|
|
153
|
+
availablePort = await getAvailablePort({...netOptions, port}, hosts); // eslint-disable-line no-await-in-loop
|
|
145
154
|
}
|
|
146
155
|
|
|
147
|
-
|
|
156
|
+
if (reserve) {
|
|
157
|
+
reservedPorts.add(availablePort);
|
|
158
|
+
} else {
|
|
159
|
+
lockedPorts.young.add(availablePort);
|
|
160
|
+
}
|
|
148
161
|
|
|
149
162
|
return availablePort;
|
|
150
163
|
} catch (error) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@micromag/recorder",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.63",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "",
|
|
6
6
|
"keywords": [
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"dependencies": {
|
|
60
60
|
"@babel/runtime": "^7.28.6",
|
|
61
61
|
"@folklore/fetch": "^0.1.14",
|
|
62
|
-
"@micromag/viewer": "^0.4.
|
|
62
|
+
"@micromag/viewer": "^0.4.63",
|
|
63
63
|
"express": "^5.2.1",
|
|
64
64
|
"get-port": "^7.1.0",
|
|
65
65
|
"lodash": "^4.17.23",
|
|
@@ -72,5 +72,5 @@
|
|
|
72
72
|
"access": "public",
|
|
73
73
|
"registry": "https://registry.npmjs.org/"
|
|
74
74
|
},
|
|
75
|
-
"gitHead": "
|
|
75
|
+
"gitHead": "0a6df1a5352c067c3296377d26fadb9b71244345"
|
|
76
76
|
}
|