@vercube/devkit 0.0.46 → 0.0.48
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/index.mjs +28 -5
- package/package.json +11 -11
package/dist/index.mjs
CHANGED
|
@@ -226,22 +226,47 @@ function createDevServer(app) {
|
|
|
226
226
|
let reloadPromise;
|
|
227
227
|
let currentFork;
|
|
228
228
|
/**
|
|
229
|
+
* Terminates a worker and resolves only once it has fully exited, so the
|
|
230
|
+
* resources it owns (the HTTP port and any message-queue consumers) are
|
|
231
|
+
* released before a replacement is spawned.
|
|
232
|
+
*
|
|
233
|
+
* A graceful SIGTERM may not stop a worker that holds long-lived handles —
|
|
234
|
+
* e.g. an open message-queue connection keeps the event loop alive — so fall
|
|
235
|
+
* back to SIGKILL after a short grace period.
|
|
236
|
+
* @param {ChildProcess} worker - The worker process to terminate.
|
|
237
|
+
* @returns {Promise<void>} A promise that resolves when the worker has exited.
|
|
238
|
+
*/
|
|
239
|
+
function killWorker(worker) {
|
|
240
|
+
if (worker.exitCode !== null || worker.signalCode !== null) return Promise.resolve();
|
|
241
|
+
return new Promise((resolve) => {
|
|
242
|
+
const killTimer = setTimeout(() => worker.kill("SIGKILL"), 1e3);
|
|
243
|
+
worker.once("exit", () => {
|
|
244
|
+
clearTimeout(killTimer);
|
|
245
|
+
resolve();
|
|
246
|
+
});
|
|
247
|
+
worker.kill("SIGTERM");
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
229
251
|
* Reloads the fork by killing the old one and creating a new one.
|
|
230
252
|
* @returns {Promise<void>} A promise that resolves when the fork is reloaded.
|
|
231
253
|
*/
|
|
232
254
|
async function _reload() {
|
|
233
255
|
const oldFork = currentFork;
|
|
234
256
|
currentFork = void 0;
|
|
235
|
-
oldFork
|
|
257
|
+
if (oldFork) await killWorker(oldFork);
|
|
236
258
|
currentFork = fork(forkEntry);
|
|
237
|
-
if (!currentFork) return;
|
|
238
259
|
}
|
|
239
260
|
/**
|
|
240
261
|
* Reloads the fork.
|
|
262
|
+
*
|
|
263
|
+
* Reloads are serialized: overlapping file-change events chain onto the
|
|
264
|
+
* previous reload instead of running concurrently, which would otherwise
|
|
265
|
+
* spawn a second worker while another is still shutting down.
|
|
241
266
|
* @returns {Promise<void>} A promise that resolves when the worker is reloaded.
|
|
242
267
|
*/
|
|
243
268
|
const reload = () => {
|
|
244
|
-
reloadPromise = _reload().then(() => {
|
|
269
|
+
reloadPromise = (reloadPromise ?? Promise.resolve()).then(() => _reload()).then(() => {
|
|
245
270
|
consola.success({
|
|
246
271
|
tag: "worker",
|
|
247
272
|
message: "Worker reloaded successfully"
|
|
@@ -252,8 +277,6 @@ function createDevServer(app) {
|
|
|
252
277
|
message: "Failed to reload worker",
|
|
253
278
|
error
|
|
254
279
|
});
|
|
255
|
-
}).finally(() => {
|
|
256
|
-
reloadPromise = void 0;
|
|
257
280
|
});
|
|
258
281
|
return reloadPromise;
|
|
259
282
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vercube/devkit",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.48",
|
|
4
4
|
"description": "Devkit module for Vercube framework",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -22,19 +22,19 @@
|
|
|
22
22
|
"README.md"
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@oxc-project/runtime": "0.
|
|
26
|
-
"c12": "4.0.0-beta.
|
|
25
|
+
"@oxc-project/runtime": "0.133.0",
|
|
26
|
+
"c12": "4.0.0-beta.5",
|
|
27
27
|
"chokidar": "5.0.0",
|
|
28
28
|
"consola": "3.4.2",
|
|
29
|
-
"defu": "6.1.
|
|
30
|
-
"dotenv": "17.
|
|
31
|
-
"hookable": "6.1.
|
|
32
|
-
"oxc-parser": "0.
|
|
33
|
-
"oxc-transform": "0.
|
|
29
|
+
"defu": "6.1.7",
|
|
30
|
+
"dotenv": "17.4.2",
|
|
31
|
+
"hookable": "6.1.1",
|
|
32
|
+
"oxc-parser": "0.133.0",
|
|
33
|
+
"oxc-transform": "0.133.0",
|
|
34
34
|
"pathe": "2.0.3",
|
|
35
|
-
"rolldown": "1.0.
|
|
36
|
-
"unplugin-isolated-decl": "0.
|
|
37
|
-
"@vercube/core": "0.0.
|
|
35
|
+
"rolldown": "1.0.2",
|
|
36
|
+
"unplugin-isolated-decl": "0.16.0",
|
|
37
|
+
"@vercube/core": "0.0.48"
|
|
38
38
|
},
|
|
39
39
|
"publishConfig": {
|
|
40
40
|
"access": "public"
|