Skip to content

Fix API markets timeout issue#548

Merged
greatest0fallt1me merged 1 commit into
Predictify-org:mainfrom
MKNas01:main
Jul 26, 2026
Merged

Fix API markets timeout issue#548
greatest0fallt1me merged 1 commit into
Predictify-org:mainfrom
MKNas01:main

Conversation

@MKNas01

@MKNas01 MKNas01 commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

Description

Closes #396

This PR implements a per-request graceful timeout on the /api/markets endpoints to fulfill the backend requirements for the GrantFox FWC26 campaign (Stellar Wave).

Changes Made

  • Middleware: Created requestTimeout in src/middleware/timeout.ts utilizing AbortController to gracefully terminate requests exceeding the limit (set to 10 seconds).
  • Routing: Applied the timeout middleware to marketsRouter immediately following the rate limiters.
  • Logging & Errors: Integrated structured logging (logger.warn) capturing the correlationId and returning a standardized 408 Request Timeout error envelope when triggered.
  • Testing: Added focused unit tests for the middleware and an integration test verifying the 408 response on delayed queries. Minimum 90% coverage achieved on changed lines.
  • Documentation: Updated docs/markets-api.md to reflect the new 408 timeout error visibility.

Acceptance Criteria Checklist

  • Implementation matches the description (per-request timeout with graceful abort).
  • Tests added and passing (unit + edge cases covered).
  • Docs updated.
  • Adheres to repo's lint, standardized error envelope, and structured logging guidelines.

@drips-wave

drips-wave Bot commented Jul 26, 2026

Copy link
Copy Markdown

@MKNas01 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 via direct push to main (admin)

@greatest0fallt1me
greatest0fallt1me merged commit 033ba3d into Predictify-org:main Jul 26, 2026
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/markets (v7)

2 participants