Skip to content

fix: make LinkedEvents API timeout configurable#455

Merged
mhieta merged 2 commits into
mainfrom
PT-1992/read-timeout-fix
Jan 22, 2026
Merged

fix: make LinkedEvents API timeout configurable#455
mhieta merged 2 commits into
mainfrom
PT-1992/read-timeout-fix

Conversation

@mhieta

@mhieta mhieta commented Jan 21, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Make LinkedEvents API timeout configurable via environment variable
  • Increase default timeout from 20s to 60s to prevent ReadTimeout errors
  • Add comprehensive tests for the timeout configuration

Problem

The LinkedEvents API client had a hardcoded 20-second timeout that was
causing ReadTimeout errors when the external API experienced high load
or network latency (Sentry issue 89742127).

Solution

  • Add LINKED_EVENTS_API_TIMEOUT environment variable (default: 60s)
  • Read timeout from config in LinkedEventsApiClient instead of using
    a hardcoded class constant
  • Maintain backward compatibility with a sensible default

Changes

palvelutarjotin/settings.py

  • Add LINKED_EVENTS_API_TIMEOUT env variable definition
  • Add TIMEOUT key to LINKED_EVENTS_API_CONFIG

graphene_linked_events/rest_client.py

  • Remove hardcoded CONNECTION_TIMEOUT = 20 class variable
  • Read timeout from config with fallback to 60s
  • Update all HTTP methods to use the configurable timeout

graphene_linked_events/tests/test_rest_client.py

  • Add tests for timeout configuration
  • Add tests verifying all HTTP methods use the configured timeout

Configuration

Default is 60 seconds, can be adjusted per environment

LINKED_EVENTS_API_TIMEOUT=90

References

Jira: PT-1992

The hardcoded 20-second timeout was causing ReadTimeout errors
when the external LinkedEvents API experienced high load or
network latency.

Changes:
- Add LINKED_EVENTS_API_TIMEOUT env variable (default: 60s)
- Read timeout from config in LinkedEventsApiClient
- Remove hardcoded CONNECTION_TIMEOUT constant

Resolves Sentry issue 89742127.

Refs: PT-1992
Add tests for the configurable timeout feature:
- Test timeout value is read from config
- Test default timeout (60s) when not configured
- Test all HTTP methods pass timeout to requests

Refs: PT-1992
@mhieta mhieta force-pushed the PT-1992/read-timeout-fix branch from f371bf0 to 26992fc Compare January 21, 2026 09:38
@sonarqubecloud

Copy link
Copy Markdown

@azure-pipelines

Copy link
Copy Markdown

KULTUS-API branch is deployed to platta: https://kultus-pr455.api.dev.hel.ninja 🚀🚀🚀

@mhieta mhieta marked this pull request as ready for review January 21, 2026 10:18
@mhieta mhieta requested a review from a team as a code owner January 21, 2026 10:18
@azure-pipelines

Copy link
Copy Markdown

KULTUS-API branch is deployed to platta: https://kultus-pr455.api.dev.hel.ninja 🚀🚀🚀

Comment thread palvelutarjotin/settings.py
@mhieta mhieta merged commit 5b92efa into main Jan 22, 2026
26 checks passed
@mhieta mhieta deleted the PT-1992/read-timeout-fix branch January 22, 2026 14:15
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.

2 participants