Skip to content

Commit e31220e

Browse files
committed
Wait for all dependencies before attempting to deploy environment. Add debug logging for paymaster.
1 parent 30542c3 commit e31220e

1 file changed

Lines changed: 21 additions & 5 deletions

File tree

packages/delegator-e2e/src/await-dependencies.ts

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@ const POLL_INTERVAL_MS = 1_000;
1616
const TIMEOUT_MS = 5 * 60_000;
1717
let hasTimedOut = false;
1818

19-
const waitFor = async (name: string, url: string) => {
19+
const waitFor = async (
20+
name: string,
21+
url: string,
22+
debugLoggingEnabled: boolean = false,
23+
) => {
2024
let isAvailable: boolean | undefined = undefined;
2125

2226
console.log(`Waiting for ${name}, at ${url}`);
@@ -27,7 +31,13 @@ const waitFor = async (name: string, url: string) => {
2731
});
2832

2933
do {
34+
if (debugLoggingEnabled) {
35+
console.log(`Checking ${name}...`);
36+
}
3037
if (isAvailable !== undefined) {
38+
if (debugLoggingEnabled) {
39+
console.log(`Waiting for ${name}...`);
40+
}
3141
// Only add a delay if it's not the first time
3242
await new Promise((resolve) => setTimeout(resolve, POLL_INTERVAL_MS));
3343
}
@@ -36,7 +46,14 @@ const waitFor = async (name: string, url: string) => {
3646
.request({ method: 'web3_clientVersion' })
3747
.then(() => (isAvailable = true))
3848
// as soon as the node is responding (even if it's MethodNotFoundRpcError)
39-
.catch((e) => (isAvailable = (e as Error).name !== 'HttpRequestError'));
49+
.catch((e) => {
50+
isAvailable = (e as Error).name !== 'HttpRequestError';
51+
if (debugLoggingEnabled) {
52+
console.log(
53+
`${name} is ${isAvailable ? 'available' : 'unavailable'}: ${e.name}`,
54+
);
55+
}
56+
});
4057
} while (!isAvailable && !hasTimedOut);
4158

4259
if (isAvailable) {
@@ -69,11 +86,10 @@ const deployEnvironment = async () => {
6986

7087
const timeoutRef = setTimeout(() => (hasTimedOut = true), TIMEOUT_MS);
7188

72-
await waitFor('Blockchain node', nodeUrl);
73-
7489
const waitingForDependencies = Promise.all([
90+
waitFor('Blockchain node', nodeUrl),
7591
waitFor('Bundler', bundlerUrl),
76-
waitFor('Mock paymaster', paymasterUrl),
92+
waitFor('Mock paymaster', paymasterUrl, true),
7793
]);
7894

7995
const environment = await deployEnvironment();

0 commit comments

Comments
 (0)