Skip to content

Commit f7e1104

Browse files
Skip external fetches in mocks mode
Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
1 parent a2af415 commit f7e1104

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

app/utils/password.server.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@ function getPasswordHashParts(password: string) {
7575
}
7676

7777
async function checkIsCommonPassword(password: string) {
78+
// In mocks mode we don't want to make external HTTP requests for password
79+
// strength checks (it can hang CI / e2e test runs and adds nondeterminism).
80+
if (process.env.MOCKS === 'true') return false
81+
7882
const [prefix, suffix] = getPasswordHashParts(password)
7983
try {
8084
const response = await fetchWithTimeout(

app/utils/user-info.server.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,13 @@ export async function gravatarExistsForEmail({
4242
staleWhileRevalidate: 1000 * 60 * 60 * 24 * 365,
4343
checkValue: (prevValue) => typeof prevValue === 'boolean',
4444
getFreshValue: async (context) => {
45+
// In mocks mode we should not make external HTTP requests (can hang/flake
46+
// CI/e2e runs, especially with Node v24 fetch abort issues).
47+
if (process.env.MOCKS === 'true') {
48+
context.metadata.ttl = 1000 * 60 * 60 * 24 * 365
49+
return false
50+
}
51+
4552
const gravatarUrl = getAvatar(email, { fallback: '404' })
4653
try {
4754
const timeoutMs = context.background || forceFresh ? 1000 * 10 : 100

0 commit comments

Comments
 (0)