@jsenv/test 3.5.1 → 3.5.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.
@@ -5499,13 +5499,21 @@ const startServerUsingCommand = async (
5499
5499
  // stderr.on("line", (data) => {
5500
5500
  // logger.debug(`[pid=${spawnedProcess.pid}][err] ${data}`);
5501
5501
  // });
5502
+ let isAbort = false;
5503
+ let isTeardown = false;
5502
5504
  let processClosed = false;
5503
5505
  const closedPromise = new Promise((resolve) => {
5504
5506
  spawnedProcess.once("exit", (exitCode, signal) => {
5505
- logger.debug(
5506
- `[pid=${spawnedProcess.pid}] <process did exit: exitCode=${exitCode}, signal=${signal}>`,
5507
- );
5508
5507
  processClosed = true;
5508
+ if (isAbort || isTeardown) {
5509
+ logger.debug(
5510
+ `web server process exit exitCode=${exitCode}, exitSignal=${signal}, pid=${spawnedProcess.pid}`,
5511
+ );
5512
+ } else {
5513
+ logger.error(
5514
+ `web server process premature exit exitCode=${exitCode}, exitSignal=${signal}, pid=${spawnedProcess.pid}`,
5515
+ );
5516
+ }
5509
5517
  resolve();
5510
5518
  });
5511
5519
  });
@@ -5550,8 +5558,14 @@ const startServerUsingCommand = async (
5550
5558
  const startOperation = Abort.startOperation();
5551
5559
  startOperation.addAbortSignal(signal);
5552
5560
  const timeoutAbortSource = startOperation.timeout(allocatedMs);
5553
- startOperation.addAbortCallback(killProcess);
5554
- teardownCallbackSet.add(killProcess);
5561
+ startOperation.addAbortCallback(async () => {
5562
+ isAbort = true;
5563
+ await killProcess();
5564
+ });
5565
+ teardownCallbackSet.add(async () => {
5566
+ isTeardown = true;
5567
+ await killProcess();
5568
+ });
5555
5569
 
5556
5570
  const startedPromise = (async () => {
5557
5571
  const logScale = [100, 250, 500];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsenv/test",
3
- "version": "3.5.1",
3
+ "version": "3.5.2",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -39,13 +39,21 @@ export const startServerUsingCommand = async (
39
39
  // stderr.on("line", (data) => {
40
40
  // logger.debug(`[pid=${spawnedProcess.pid}][err] ${data}`);
41
41
  // });
42
+ let isAbort = false;
43
+ let isTeardown = false;
42
44
  let processClosed = false;
43
45
  const closedPromise = new Promise((resolve) => {
44
46
  spawnedProcess.once("exit", (exitCode, signal) => {
45
- logger.debug(
46
- `[pid=${spawnedProcess.pid}] <process did exit: exitCode=${exitCode}, signal=${signal}>`,
47
- );
48
47
  processClosed = true;
48
+ if (isAbort || isTeardown) {
49
+ logger.debug(
50
+ `web server process exit exitCode=${exitCode}, exitSignal=${signal}, pid=${spawnedProcess.pid}`,
51
+ );
52
+ } else {
53
+ logger.error(
54
+ `web server process premature exit exitCode=${exitCode}, exitSignal=${signal}, pid=${spawnedProcess.pid}`,
55
+ );
56
+ }
49
57
  resolve();
50
58
  });
51
59
  });
@@ -90,8 +98,14 @@ export const startServerUsingCommand = async (
90
98
  const startOperation = Abort.startOperation();
91
99
  startOperation.addAbortSignal(signal);
92
100
  const timeoutAbortSource = startOperation.timeout(allocatedMs);
93
- startOperation.addAbortCallback(killProcess);
94
- teardownCallbackSet.add(killProcess);
101
+ startOperation.addAbortCallback(async () => {
102
+ isAbort = true;
103
+ await killProcess();
104
+ });
105
+ teardownCallbackSet.add(async () => {
106
+ isTeardown = true;
107
+ await killProcess();
108
+ });
95
109
 
96
110
  const startedPromise = (async () => {
97
111
  const logScale = [100, 250, 500];
@@ -1,5 +1,4 @@
1
1
  import { assertAndNormalizeDirectoryUrl } from "@jsenv/filesystem";
2
-
3
2
  import { basicFetch } from "../helpers/basic_fetch.js";
4
3
  import { pingServer } from "../helpers/ping_server.js";
5
4
  import { startServerUsingCommand } from "./web_server/start_using_command.js";