Skip to content

Give the pad render's owner-profile and Auth reads their own deadlines #596

Closed

Description

@HMarzban

Goal

A slow owner-profile read must not send the server render of an owned pad to /500. Give that read, and the Auth read, their own deadlines.

Facts

Code references are at b131fc7b1. The series ratio was measured locally on 2026-10-23; the rest is read from code.

  • GET /api/documents/:docName runs its upstream hops in series (measured ratio 1.04).
  • The server's SUPABASE_FETCH_TIMEOUT_MS = 10_000 (apps/hocuspocus.server/src/lib/supabase.ts:9) equals the webapp abort at apps/webapp/src/utils/fetchDocument.ts:85.
  • The server starts its deadline later. So a null profile caused by that deadline always arrives after the webapp has aborted.
  • So a PostgREST stall near 10 s sends every server render of an owned pad to /500, for visitors too.
  • The rate-limiter Redis read is a fourth hop on the same budget.

What to build

  1. In getOwnerProfile (apps/hocuspocus.server/src/lib/profiles.ts), give the read its own deadline of about 1500–2000 ms, through .abortSignal() and controller.abort(). On timeout, render with a null owner profile.
  2. auth-js getUser takes no signal. So bound the Auth hop with a timer race in optionalUser (apps/hocuspocus.server/src/api/middleware/auth.ts), mapped to unavailable.
  3. That race must not write the negative token cache.

Out of scope

  • A profile TTL cache. It conflicts with Settings live sync.

Acceptance criteria

  • With a stalled profile read, the route answers within the new deadline, with a null owner profile.
  • A stalled getUser maps to unavailable, and the negative cache stays empty.
  • Remove the deadline locally, and see the test time out. Restore it.
  • The tests run in bun test on every pull request.

Effort and order

Effort S. No blocker. Impact is 2–3, because the production stall rate is unknown. #576 reads it.


Parent: #575. Source: the 2026-10-23 backend perf plan, refined on 2026-10-24.

Activity

  1. added this to the v2.3.0 milestone on Oct 24, 2026
  2. added
    bug
    Performance
    on Oct 24, 2026
  3. HMarzban commented on Oct 25, 2026

    @HMarzban
    CollaboratorAuthor

    Built and committed on local main. Awaits the maintainer's final push.

    Remaining gate: the backend deploy. Then the pad render answers within about 2 s when the profile or Auth read stalls.

  4. modified the milestones: v2.3.0, v2.3.6 on Nov 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Performancebug

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions