Skip to content

Commit 145f90c

Browse files
Merge branch 'feature/add-logic-to-send-telemetry-data' of github.com:NomicFoundation/hardhat into features/port-sentry-to-V3
2 parents e429d8e + 3e59fa5 commit 145f90c

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

v-next/hardhat/src/internal/cli/telemetry/telemetry-permissions.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,15 @@ export async function isTelemetryAllowed(): Promise<boolean> {
4747
return false;
4848
}
4949

50-
const consent = await getTelemetryConsent();
51-
5250
// ATTENTION: only for testing
5351
if (process.env.HARDHAT_TEST_TELEMETRY_CONSENT_VALUE !== undefined) {
5452
return process.env.HARDHAT_TEST_TELEMETRY_CONSENT_VALUE === "true"
5553
? true
5654
: false;
5755
}
5856

57+
const consent = await getTelemetryConsent();
58+
5959
return consent !== undefined ? consent : false;
6060
}
6161

@@ -72,7 +72,8 @@ export function isTelemetryAllowedInEnvironment(): boolean {
7272
(!isCi() &&
7373
process.stdout.isTTY === true &&
7474
process.env.HARDHAT_DISABLE_TELEMETRY_PROMPT !== "true") ||
75-
process.env.HARDHAT_TEST_INTERACTIVE_ENV === "true" // Used in tests to force telemetry execution
75+
// ATTENTION: used in tests to force telemetry execution
76+
process.env.HARDHAT_TEST_INTERACTIVE_ENV === "true"
7677
);
7778
}
7879

v-next/hardhat/test/internal/cli/telemetry/helpers.ts

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import path from "node:path";
22

3-
import { exists } from "@ignored/hardhat-vnext-utils/fs";
3+
import { exists, readUtf8File } from "@ignored/hardhat-vnext-utils/fs";
44

55
export const ROOT_PATH_TO_FIXTURE: string = path.join(
66
process.cwd(),
@@ -33,12 +33,15 @@ export async function checkIfSubprocessWasExecuted(
3333
counter++;
3434

3535
if (await exists(resultFilePath)) {
36-
clearInterval(intervalId);
37-
resolve(true);
36+
try {
37+
await readUtf8File(resultFilePath); // Wait for the file to be readable
38+
clearInterval(intervalId);
39+
resolve(true);
40+
} catch (_err) {}
3841
} else if (counter > MAX_COUNTER) {
3942
clearInterval(intervalId);
4043
reject("Subprocess was not executed in the expected time");
4144
}
42-
}, 100);
45+
}, 50);
4346
});
4447
}

0 commit comments

Comments
 (0)