Skip to content

Commit 19bf665

Browse files
committed
Revert "try: copilot fix verdaccio hangs"
This reverts commit 55ca895.
1 parent 8de0577 commit 19bf665

2 files changed

Lines changed: 21 additions & 40 deletions

File tree

.ado/scripts/verdaccio.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ case ${1-} in
1313
"init")
1414
npm set registry $NPM_REGISTRY
1515
scripts_root=$(cd -P "$(dirname $0)" && pwd)
16+
node $scripts_root/waitForVerdaccio.mjs $NPM_REGISTRY
1617
node $scripts_root/npmAddUser.mjs user pass mail@nomail.com $NPM_REGISTRY
1718
;;
1819

.ado/scripts/waitForVerdaccio.mjs

Lines changed: 20 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -4,48 +4,28 @@
44
import * as fs from "node:fs";
55
import { get } from "node:http";
66

7-
const REGISTRY_URL = process.argv[2] || "http://localhost:4873";
8-
const TIMEOUT_MS = Number(process.env.VERDACCIO_WAIT_TIMEOUT_MS || 60_000);
9-
const POLL_MS = Number(process.env.VERDACCIO_WAIT_POLL_MS || 1_000);
10-
11-
// Construct a ping URL that's supported by Verdaccio
12-
const pingUrl = new URL(REGISTRY_URL);
13-
// Ensure we hit the ping endpoint regardless of trailing slash
14-
pingUrl.pathname = (pingUrl.pathname?.replace(/\/*$/, "") || "") + "/-/ping";
15-
16-
const deadline = Date.now() + TIMEOUT_MS;
17-
18-
function dumpLogs() {
19-
try {
20-
// Verdaccio config logs to .ado/verdaccio/verdaccio.log
21-
const logUrl = new URL("../verdaccio/verdaccio.log", import.meta.url);
22-
const logFile = fs.readFileSync(logUrl, { encoding: "utf-8" });
23-
console.log("\n--- Verdaccio log ---\n" + logFile + "\n--- end log ---\n");
24-
} catch {
25-
console.log("No Verdaccio log output yet.");
26-
}
27-
}
28-
29-
function check() {
30-
if (Date.now() > deadline) {
31-
console.error(`Timed out waiting for Verdaccio at ${pingUrl.href}`);
32-
dumpLogs();
33-
process.exit(1);
34-
}
35-
36-
get(pingUrl, res => {
37-
if (res.statusCode === 200) {
38-
console.log("Verdaccio is ready: " + pingUrl.href);
39-
process.exit(0);
40-
} else {
41-
console.log(`Verdaccio status: ${res.statusCode}; retrying in ${POLL_MS}ms`);
42-
setTimeout(check, POLL_MS);
7+
/**
8+
* @param {string} npmRegistryUrl
9+
*/
10+
function queryForServerStatus(npmRegistryUrl) {
11+
get(npmRegistryUrl, res => {
12+
console.log(`Verdaccio server status: ${res.statusCode}`);
13+
if (res.statusCode != 200) {
14+
setTimeout(queryForServerStatus, 2000);
4315
}
4416
}).on("error", err => {
45-
console.log(`Verdaccio not ready (${err.message}); retrying in ${POLL_MS}ms`);
46-
setTimeout(check, POLL_MS);
17+
console.log(err.message);
18+
const logUrl = new URL("../verdaccio/console.log", import.meta.url);
19+
try {
20+
const logFile = fs.readFileSync(logUrl, { encoding: "utf-8" });
21+
console.log("Verdaccio console output: " + logFile);
22+
} catch (error) {
23+
console.log("No Verdaccio console output yet.");
24+
}
25+
setTimeout(queryForServerStatus, 2000);
4726
});
4827
}
4928

50-
console.log(`Waiting for Verdaccio to respond at ${pingUrl.href} (timeout ${TIMEOUT_MS}ms)...`);
51-
check();
29+
console.log("Waiting for Verdaccio instance to respond...");
30+
31+
queryForServerStatus(process.argv[2]);

0 commit comments

Comments
 (0)