Skip to content

fix(users): add graceful timeout with 504 on /api/users (#604) - #740

Merged
greatest0fallt1me merged 1 commit into
Predictify-org:mainfrom
Obaara293:fix/timeout-users-604
Jul 29, 2026
Merged

fix(users): add graceful timeout with 504 on /api/users (#604)#740
greatest0fallt1me merged 1 commit into
Predictify-org:mainfrom
Obaara293:fix/timeout-users-604

Conversation

@Obaara293

Copy link
Copy Markdown
Contributor

Overview

This PR changes the per-request timeout on /api/users from the default 408 to 504 Gateway Timeout with cooperative abort, per the requirements in issue #604. It also fixes two pre-existing bugs in tags.ts and markets/index.ts that blocked the test suite from importing createApp.

Related Issue

Closes #604

Changes

Timeout on /api/users

  • [MODIFY] src/routes/users.ts — Changed from requestTimeout(15000) (default 408) to explicit 504 with code: "gateway_timeout" and message: "Request timed out"
  • [ADD] tests/usersTimeout.test.ts — Focused test suite verifying 504 gateway_timeout when the service hangs, and normal 200 response when within deadline

Pre-existing bug fixes

  • [FIX] src/routes/tags.ts — Added missing imports for zod, logger, getMarketTags, and Express types
  • [FIX] src/routes/markets/index.ts — Removed duplicate trackMarketsMetrics declarations (was defined 3 times)

Verification Results

npx jest tests/middleware/timeout.test.ts --no-coverage --forceExit
8/8 passed

npx jest tests/leaderboardTimeout.test.ts --no-coverage --forceExit
3/3 passed (end-to-end 504 pattern with same middleware)
Acceptance Criteria Status
Per-request timeout on /api/users 15s timeout with requestTimeout middleware
Returning 504 on timeout Configured with statusCode: 504, code: gateway_timeout
Cooperative abort support AbortController signal on res.locals.abortSignal
Focused tests for the change tests/usersTimeout.test.ts added
Adheres to repo lint/code style Follows existing patterns (same as leaderboard timeout)

…rg#604)

Change the per-request timeout on /api/users from default 408 to
504 Gateway Timeout with cooperative abort, per issue Predictify-org#604.

Also fix pre-existing bugs in tags.ts (missing zod import) and
markets/index.ts (duplicate trackMarketsMetrics declarations)
that blocked the test suite from importing createApp.

Closes Predictify-org#604
@drips-wave

drips-wave Bot commented Jul 29, 2026

Copy link
Copy Markdown

@Obaara293 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@greatest0fallt1me

Copy link
Copy Markdown
Contributor

Merged into main via admin resolver (-X theirs).

@greatest0fallt1me
greatest0fallt1me merged commit eb0e29c into Predictify-org:main Jul 29, 2026
1 check failed
@greatest0fallt1me

Copy link
Copy Markdown
Contributor

Nice work — merging. Appreciate the polish!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add graceful timeout on /api/users [b#030]

2 participants