Skip to content

Commit e188515

Browse files
Use MSW for external password checks
Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
1 parent 88820c8 commit e188515

File tree

3 files changed

+2
-13
lines changed

3 files changed

+2
-13
lines changed

app/utils/password.server.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,6 @@ 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-
8278
const [prefix, suffix] = getPasswordHashParts(password)
8379
try {
8480
const response = await fetchWithTimeout(

app/utils/user-info.server.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,6 @@ 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-
5245
const gravatarUrl = getAvatar(email, { fallback: '404' })
5346
try {
5447
const timeoutMs = context.background || forceFresh ? 1000 * 10 : 100

mocks/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ const miscHandlers = [
5454
},
5555
),
5656
http.head('https://www.gravatar.com/avatar/:md5Hash', async () => {
57-
if (await isConnectedToTheInternet()) return passthrough()
58-
57+
// In mocks mode we want deterministic behavior and to avoid external HTTP
58+
// requests that can flake in CI (even when DNS works).
5959
return HttpResponse.json(null, { status: 404 })
6060
}),
6161
http.get(/http:\/\/(localhost|127\.0\.0\.1):\d+\/.*/, async () =>

0 commit comments

Comments
 (0)