Skip to content

Commit 2b9d7a4

Browse files
refactor: remove wait-on dependency (#2092)
* refactor: remove wait-on dependency Replace external wait-on package with inline waitForServer function. This reduces transitive dependencies (including axios) while providing equivalent functionality for the fake-extension dev script. * Add request timeout to waitForServer Co-authored-by: jkingston <[email protected]> * Refactor waitForServer function for improved timeout handling * Lint fix --------- Co-authored-by: Cursor Agent <[email protected]>
1 parent 791d0c2 commit 2b9d7a4

File tree

4 files changed

+24
-458
lines changed

4 files changed

+24
-458
lines changed

injected/scripts/run-fake-extension.js

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#!/usr/bin/env node
22
import { spawn } from 'child_process';
3-
import waitOn from 'wait-on';
43
import path from 'path';
54
import { fileURLToPath } from 'url';
65

@@ -25,6 +24,27 @@ function run(cmd, args, opts = {}) {
2524
});
2625
}
2726

27+
/**
28+
* Wait for a URL to become available.
29+
* @param {string} url - The URL to poll
30+
* @param {number} [timeout=30000] - Timeout in milliseconds
31+
* @param {number} [interval=500] - Polling interval in milliseconds
32+
* @returns {Promise<void>}
33+
*/
34+
async function waitForServer(url, timeout = 30000, interval = 500) {
35+
const deadline = Date.now() + timeout;
36+
while (Date.now() < deadline) {
37+
try {
38+
const response = await fetch(url, { signal: AbortSignal.timeout(5000) });
39+
if (response.ok) return;
40+
} catch {
41+
// Server not ready yet
42+
}
43+
await new Promise((resolve) => setTimeout(resolve, interval));
44+
}
45+
throw new Error(`Timeout waiting for ${url}`);
46+
}
47+
2848
async function main() {
2949
// 1. Build
3050
await run('npm', ['run', 'build']);
@@ -60,7 +80,7 @@ async function main() {
6080
});
6181

6282
// 3. Wait for server
63-
await waitOn({ resources: ['http://localhost:3220/index.html'] });
83+
await waitForServer('http://localhost:3220/index.html');
6484

6585
// 4. Run web-ext
6686
try {

0 commit comments

Comments
 (0)