Skip to content

How long to wait after a rate limit is worded in three places, and the OAuth pages can say "1 seconds" #679

Closed

Description

@richshaw

Needs your OK: this changes the wait shown on the two OAuth "too many requests" pages from seconds to minutes for waits under two minutes. Swap pipeline:proposed for pipeline:ready to have it built.

What happens

When someone hits a rate limit, the page tells them how long to wait. That wording is worked out in three places:

  • Participant sign-up errors: rateLimitMessage in src/app/s/[slug]/rate-limit-message.ts. It rounds up to whole minutes, never under one: "Try again in about 2 minutes."
  • The new-signup form: createSignupAction in src/app/app/(chrome)/signups/new/actions.ts. It has the same rule, copied by hand (Math.max(1, Math.ceil(retryAfter / 60)) and the same plural).
  • OAuth: describeWait in src/oauth/provider.ts, used by src/oauth/handler.ts and src/app/oauth/consent/[uid]/decision/route.ts. It gives seconds under 120 and minutes from 120 on.

The verifier called the real functions:

wait (s) participant page new-signup form OAuth pages
1 1 minute 1 minute 1 seconds
60 1 minute 1 minute 60 seconds
90 2 minutes 2 minutes 90 seconds
119 2 minutes 2 minutes 119 seconds
120 2 minutes 2 minutes 2 minutes
3412 57 minutes 57 minutes 57 minutes

"1 seconds" really happens. chargeRateLimit returns at least 1 second, and exactly 1 in the last second of a window. The OAuth authorize limit (600 s window) and the consent limit (3600 s window) are long enough to land there. A person reads these pages: the handler renders HTML only for a browser, and API clients get JSON.

Open PR #572 adds a fourth copy for Magic Compose (minutesToWait in src/components/magic-compose/draft-errors.ts).

Fix, in outline

  • Add one helper next to formatDuration in src/lib/format-duration.ts, which already has a private pluralize. For example waitInMinutes(seconds), giving "1 minute", "2 minutes" and so on, rounded up and never under one.
  • Use it in rateLimitMessage (keep its "a few minutes" fallback for a missing wait), in createSignupAction, and in both OAuth callers. Delete describeWait.
  • Once Say when the hour's AI drafts are used up, in plain words #572 has merged, have minutesToWait in draft-errors.ts use the same rounding: either the helper, or one shared minutes function the helper is built on. Its "missing wait" fallbacks (60 for the hourly limit, 1 for the provider) stay as they are.

Watch for

  • Tests that pin the current text:
    • src/oauth/provider.test.ts tests describeWait (7 → "7 seconds", 119 → "119 seconds"). Replace it with a waitInMinutes test in src/lib/format-duration.test.ts that covers 1, 60, 61 and 3412.
    • src/app/oauth/consent/[uid]/decision/route.test.ts mocks describeWait and expects "Wait 600 seconds". Expect "Wait 10 minutes" instead.
    • handler.test.ts, rate-limit-message.test.ts, commit-dialog.test.tsx and actions.db.test.ts should pass unchanged.
  • src/oauth/ is on the high-risk list, so the PR stops for the owner anyway. Only the wording changes, nothing about tokens or auth.
  • src/app/api/signups/magic-compose/errors.ts prints the AI provider's own retryAfterSeconds as "30s". That's the provider's wait, not ours, and Say when the hour's AI drafts are used up, in plain words #572 rewords it for the page. Leave it out.
  • Add a CHANGELOG line under Changed for the OAuth wording.

Choices this makes

  • Minutes everywhere, rounded up. The OAuth pages change: waits of 1 to 60 seconds read "1 minute", and 61 to 119 seconds read "2 minutes". Rounding up never tells someone to come back too early, and the participant page already reads this way. The other choice is to keep seconds under two minutes on OAuth and only fix "1 seconds"; that would leave two rules.
  • The OAuth sentences keep their shape: "Too many requests. Wait 2 minutes and try again." Only the wait changes, not "about" as the participant page has.

Order

After #572, because it adds the Magic Compose copy this should fold in.

Done when

  • One helper words the wait, and rateLimitMessage, createSignupAction, both OAuth callers and Say when the hour's AI drafts are used up, in plain words #572's minutesToWait use it (or its rounding). describeWait is gone.
  • A unit test pins 1 → "1 minute", 60 → "1 minute", 61 → "2 minutes" and 3412 → "57 minutes".
  • pnpm lint && pnpm typecheck && pnpm knip && pnpm test and pnpm test:db pass (src/oauth changes).

Found by the pipeline's refactor scout in the rate-limit callers (src/lib/rate-limit.ts, src/oauth, src/app/s/[slug], the new-signup form), at a1861fb. Checked by an independent vitest run calling the real rateLimitMessage, createSignupAction and describeWait with waits from 1 to 3412 seconds. https://claude.ai/code/session_01VDxNQieDU78WZq9ygPpF7h

Activity

  1. added
    enhancement
    pipeline:ux
    pipeline:working
    and removed on Oct 26, 2026
  2. self-assigned this
    on Oct 30, 2026
  3. removed
    pipeline:working
    on Oct 30, 2026
  4. removed
    pipeline:ux
    on Oct 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancement

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions