qrusty-client 0.19.18 → 0.19.19

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/live_test.js +27 -0
  2. package/package.json +1 -1
package/live_test.js CHANGED
@@ -67,6 +67,31 @@ function parseArgs() {
67
67
  // ---------------------------------------------------------------------------
68
68
  // Server lifecycle
69
69
  // ---------------------------------------------------------------------------
70
+
71
+ /**
72
+ * Kill any process already listening on `port` so the test starts clean.
73
+ * Prevents stale servers from prior runs causing 409 conflicts.
74
+ */
75
+ function killExistingOnPort(port) {
76
+ try {
77
+ const pids = execSync(`lsof -ti :${port}`, { encoding: "utf8" }).trim();
78
+ if (pids) {
79
+ for (const pid of pids.split("\n")) {
80
+ try {
81
+ process.kill(parseInt(pid, 10), "SIGKILL");
82
+ console.log(`Killed stale process ${pid} on port ${port}`);
83
+ } catch {
84
+ // already dead
85
+ }
86
+ }
87
+ // Brief wait for the port to be released.
88
+ execSync("sleep 1");
89
+ }
90
+ } catch {
91
+ // nothing listening, or lsof not available
92
+ }
93
+ }
94
+
70
95
  function startServer(binary, port, dataDir) {
71
96
  const env = {
72
97
  ...process.env,
@@ -167,6 +192,8 @@ async function main() {
167
192
  process.exit(2);
168
193
  }
169
194
 
195
+ killExistingOnPort(args.port);
196
+
170
197
  const dataDir = fs.mkdtempSync(path.join(os.tmpdir(), "qrusty-node-live-"));
171
198
  const baseUrl = `http://127.0.0.1:${args.port}`;
172
199
  const wsUrl = `ws://127.0.0.1:${args.port}`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "qrusty-client",
3
- "version": "0.19.18",
3
+ "version": "0.19.19",
4
4
  "description": "Node.js client for the qrusty priority queue server API.",
5
5
  "main": "index.js",
6
6
  "author": "Gordon Greene <greeng3@obscure-reference.com>",