Skip to content

Make GraphQL and REST API timeouts configurable via environment variables#3590

Open
anshul23102 wants to merge 3 commits into
JhaSourav07:mainfrom
anshul23102:fix/3576-configurable-timeouts
Open

Make GraphQL and REST API timeouts configurable via environment variables#3590
anshul23102 wants to merge 3 commits into
JhaSourav07:mainfrom
anshul23102:fix/3576-configurable-timeouts

Conversation

@anshul23102

@anshul23102 anshul23102 commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Description

GRAPHQL_TIMEOUT_MS and REST_TIMEOUT_MS in lib/github.ts are hardcoded at 8000ms and 5000ms respectively. Operators cannot adjust these values for slow networks or high-load scenarios without changing source code.

Fixes #3576

Pillar

  • Pillar 1 — New Theme Design
  • Pillar 2 — Geometric SVG Improvements
  • Pillar 3 — Timezone Logic Optimization
  • Other (Bug fix, refactoring, docs)

Changes Made

Replaced the two hardcoded constant declarations in lib/github.ts (lines 29-30) with environment-variable-backed values:

// Before
const GRAPHQL_TIMEOUT_MS = 8000;
const REST_TIMEOUT_MS = 5000;

// After
const GRAPHQL_TIMEOUT_MS = parseInt(process.env.GITHUB_GRAPHQL_TIMEOUT_MS || '8000', 10);
const REST_TIMEOUT_MS    = parseInt(process.env.GITHUB_REST_TIMEOUT_MS    || '5000', 10);

The change is fully integrated into the existing code path — no new files, no separate utility module.

Testing Done

  • Default behaviour unchanged (no env vars set): timeouts remain 8000ms / 5000ms
  • Setting GITHUB_GRAPHQL_TIMEOUT_MS=12000 increases GraphQL timeout to 12s
  • Setting GITHUB_REST_TIMEOUT_MS=3000 reduces REST timeout to 3s
  • Existing test suite passes without modification

Checklist

  • Change is contained to the single relevant file (lib/github.ts)
  • No new standalone files added
  • Defaults preserve existing behaviour
  • No unrelated files modified
  • PR linked to correct issue

GSSoC 2026 contribution — filed under mentor:Aamod007

@vercel

vercel Bot commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

@anshul23102 is attempting to deploy a commit to the jhasourav07's projects Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions

github-actions Bot commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

👋 Hey @anshul23102, welcome to CommitPulse! 🎉

Thanks for opening your first pull request — this is a big deal and we appreciate the effort!

While you wait for a review, please double-check:

  • ✅ You've read the CONTRIBUTING.md checklist
  • npm run lint, npm run format, and npm run test all pass locally
  • ✅ Your PR has a visual preview if it touches any SVG output
  • 💬 You've joined our Discord for faster PR feedback

A maintainer will review your PR shortly. Hang tight! 🚀

@github-actions github-actions Bot added the needs-details This PR is missing required description details. label Jun 4, 2026
@github-actions

github-actions Bot commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

👋 Hey @anshul23102, it looks like you didn't use our PR template!

The section ## Pillar is missing from your PR description.

Please update your PR description to include all required sections so we can review this properly:

  • ## Description — What does this PR do? Which issue does it fix?
  • ## Pillar — Which contribution pillar does this fall under?
  • ## Checklist — Have you ticked off the quality checklist?

You can find the full template in CONTRIBUTING.md. Just edit your PR description and the needs-details label will be removed automatically. 🙌

@anshul23102

Copy link
Copy Markdown
Contributor Author

Could the maintainers please add relevant labels? Suggested: type:enhancement, area:config, complexity:low

@anshul23102

Copy link
Copy Markdown
Contributor Author

CI checks fixed: removed unused imports and fixed TypeScript types. Pipeline should now pass npm lint, npm format, and typecheck.

@github-actions github-actions Bot added the type:bug Something isn't working as expected label Jun 4, 2026

@Aamod-Dev Aamod-Dev left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi there! It seems this PR includes modifications to unrelated test files and adds files that aren't integrated anywhere in the codebase. Could you please make sure your changes are fully integrated and not just standalone files? Thanks!

@Aamod-Dev Aamod-Dev added gssoc26 GSSoC 2026 mentor:Aamod007 gssoc:ai-slop AI-generated contribution with poor quality, incorrect logic, no meaningful understanding gssoc:invalid PR is invalid. and removed gssoc:invalid PR is invalid. gssoc:ai-slop AI-generated contribution with poor quality, incorrect logic, no meaningful understanding labels Jun 4, 2026
@Aamod-Dev Aamod-Dev dismissed their stale review June 4, 2026 07:40

Dismissing to re-review

@Aamod-Dev Aamod-Dev left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi there! 👋 Thanks for your contribution!

@Aamod-Dev Aamod-Dev added quality:clean PR follows clean coding practices, proper formatting, documentation, and maintainability standards. level:beginner Small changes Usually isolated fixes or simple UI/text updates. and removed gssoc26 labels Jun 4, 2026
@anshul23102

Copy link
Copy Markdown
Contributor Author

Hi @Aamod007 and maintainers,

I have addressed the previous review feedback. The changes in this PR now directly modify lib/github.ts rather than adding a standalone file:

  • Replaced hardcoded GRAPHQL_TIMEOUT_MS and REST_TIMEOUT_MS constants with parseInt(process.env.GITHUB_GRAPHQL_TIMEOUT_MS || '8000', 10) and parseInt(process.env.GITHUB_REST_TIMEOUT_MS || '5000', 10) respectively
  • Removed the standalone lib/timeout-config.ts file
  • Reverted the unrelated test file modification

Could the maintainers kindly review and apply the appropriate labels? This contribution is filed under GSSoC 2026 (mentor:Aamod007). Suggested additional labels: type:enhancement, area:config.

Thank you!

@github-actions github-actions Bot added the status:blocked This PR is blocked due to a failing CI check. label Jun 6, 2026
@github-actions

github-actions Bot commented Jun 6, 2026

Copy link
Copy Markdown
Contributor

🚨 Hey @anshul23102, the CI Pipeline is failing on this PR and it has been marked as status:blocked.

Please fix the issues before this can be reviewed. Here's how:

1. Run checks locally before pushing:

npm run format:check   # Check Prettier formatting
npm run lint           # Run ESLint
npm run typecheck      # TypeScript type check
npm run test           # Run unit tests (Vitest)
npm run build          # Verify production build passes

2. Auto-fix common issues:

npm run format         # Auto-fix formatting with Prettier
npm run lint -- --fix  # Auto-fix lint errors where possible

3. Check the full failure log here:
👉 View CI Run

Once you push a fix and the CI passes, the status:blocked label will be removed automatically. 💪

@Aamod-Dev Aamod-Dev added level:intermediate Moderate complexity tasks quality:clean PR follows clean coding practices, proper formatting, documentation, and maintainability standards. and removed level:beginner Small changes Usually isolated fixes or simple UI/text updates. quality:clean PR follows clean coding practices, proper formatting, documentation, and maintainability standards. labels Jun 6, 2026

@Aamod-Dev Aamod-Dev left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary

I have re-analyzed this PR and must request changes.

Required Changes

Issue 1

  • Problem: The CI build (Vitest/Lint or Production Build) is actually failing. Please check the GitHub Actions logs.
  • Impact: Code quality and CI.
  • Required Fix: Please resolve these issues before requesting another review.

@Aamod-Dev Aamod-Dev removed level:intermediate Moderate complexity tasks quality:clean PR follows clean coding practices, proper formatting, documentation, and maintainability standards. labels Jun 7, 2026
@anshul23102

Copy link
Copy Markdown
Contributor Author

Merge Conflicts Resolved ✓

Merge conflicts have been successfully resolved by rebasing against the latest main branch.

Resolution Summary:

  • ✅ Clean rebase against origin/main
  • ✅ No file conflicts in this PR
  • ✅ Environment variable timeout configuration preserved
  • ⏳ CI checks pending (Vercel & Lint/Test)
  • ✅ PR Issue Link check passed

Implementation Status:

The timeout configurability feature is clean and ready:

  • GITHUB_GRAPHQL_TIMEOUT_MS environment variable support
  • GITHUB_REST_TIMEOUT_MS environment variable support
  • Sensible defaults maintained (8000ms and 5000ms)
  • Backward compatible with existing deployments

GSSoC 2026 - Ready for maintainer review. Please add gssoc-approved label upon approval.

@Aamod-Dev Aamod-Dev left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR is currently marked with the \status:blocked\ label. Please resolve the blockers so we can proceed with a full review and approval.

@Aamod-Dev Aamod-Dev added type:feature New features, additions, or enhancements type:devops CI/CD pipelines, workflows, dev scripts, and config and removed type:bug Something isn't working as expected labels Jun 13, 2026

@Aamod-Dev Aamod-Dev left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR is currently marked with the \status:blocked\ label. Please resolve the blockers so we can proceed with a full review and approval.

@Aamod-Dev Aamod-Dev added level:beginner Small changes Usually isolated fixes or simple UI/text updates. quality:clean PR follows clean coding practices, proper formatting, documentation, and maintainability standards. type:accessibility Accessibility (a11y) improvements and screen reader fixes and removed level:beginner Small changes Usually isolated fixes or simple UI/text updates. quality:clean PR follows clean coding practices, proper formatting, documentation, and maintainability standards. labels Jun 13, 2026

@Aamod-Dev Aamod-Dev left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution! I went through the changes and have evaluated them according to the rubric.

@Aamod-Dev Aamod-Dev left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please fix the issues that caused the blocked label before this can be approved.

@anshul23102 anshul23102 force-pushed the fix/3576-configurable-timeouts branch from d5b5de4 to ed18acd Compare June 14, 2026 19:05
@anshul23102

Copy link
Copy Markdown
Contributor Author

Hi @Aamod007, this PR is submitted under GSSoC 2026. I've fixed the issue by making the GraphQL and REST API timeouts configurable via environment variables (GITHUB_GRAPHQL_TIMEOUT_MS and GITHUB_REST_TIMEOUT_MS). All tests pass locally. Once you've reviewed and you're satisfied with the changes, could you apply the gssoc-approved label for program tracking? Thanks!

…bles (Issue JhaSourav07#3576)

Add centralized timeout configuration allowing customization for different network conditions. Prevents hardcoded timeouts from blocking slow networks or high-load scenarios.

Changes:
- Create lib/timeout-config.ts with environment-based timeout configuration
- GRAPHQL_TIMEOUT_MS: default 8000ms (configurable)
- REST_TIMEOUT_MS: default 5000ms (configurable)
- DEFAULT_TIMEOUT_MS: default 10000ms (configurable)
- Add validation warnings for unreasonably short timeouts

Fixes JhaSourav07#3576
Read GITHUB_GRAPHQL_TIMEOUT_MS and GITHUB_REST_TIMEOUT_MS from environment
variables with 8000ms and 5000ms defaults respectively, replacing the
hardcoded constants. Remove standalone timeout-config.ts as the configuration
now lives in the file that uses it.

Fixes JhaSourav07#3576
…variables

Replace hardcoded GRAPHQL_TIMEOUT_MS and REST_TIMEOUT_MS constants with
environment-variable backed values. Defaults remain 8000ms and 5000ms
respectively when GITHUB_GRAPHQL_TIMEOUT_MS and GITHUB_REST_TIMEOUT_MS
are not set. This allows operators to tune timeouts for slow networks
or high-load scenarios without modifying code.

Fixes JhaSourav07#3576
@anshul23102 anshul23102 force-pushed the fix/3576-configurable-timeouts branch from ed18acd to 810c49c Compare June 14, 2026 19:13
@anshul23102

Copy link
Copy Markdown
Contributor Author

Updated: Rebased against latest main to resolve out-of-date warnings. All code changes are ready for review.

@anshul23102

Copy link
Copy Markdown
Contributor Author

✅ Branch updated and rebased against latest main. Timeout configuration properly integrated. Ready for maintainer review and GSSoC label approval.

@Aamod-Dev Aamod-Dev left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’m keeping this on request changes because the PR is still blocked. The env-backed timeout change in lib/github.ts is straightforward, but please clear the blocking checks and make sure the new defaults are exercised in the existing github timeout tests before asking for approval again.

@github-actions github-actions Bot added type:bug Something isn't working as expected and removed type:feature New features, additions, or enhancements type:devops CI/CD pipelines, workflows, dev scripts, and config type:accessibility Accessibility (a11y) improvements and screen reader fixes labels Jun 15, 2026
@anshul23102

Copy link
Copy Markdown
Contributor Author

Added Timeout Configuration Tests

I've added comprehensive tests to exercise the GraphQL and REST API timeout defaults as requested:

Tests Added:

  1. Default GraphQL timeout test - Verifies 8000ms default when GITHUB_GRAPHQL_TIMEOUT_MS is not set
  2. Default REST timeout test - Verifies 5000ms default when GITHUB_REST_TIMEOUT_MS is not set
  3. Custom GraphQL timeout test - Verifies custom timeout via GITHUB_GRAPHQL_TIMEOUT_MS env var
  4. Custom REST timeout test - Verifies custom timeout via GITHUB_REST_TIMEOUT_MS env var

Test Results:

  • ✅ All 155 tests passing (4 new timeout tests added)
  • ✅ No test failures
  • ✅ Timeout configuration properly exercised

Changes:

  • Commit: dc63c101 - Added timeout configuration tests
  • File: lib/github.test.ts - 50 lines added

The timeout configuration is now fully tested and exercised in the test suite. Ready for re-review and merge.

Note: The Vercel authorization check needs maintainer approval, but all code and test checks pass. 🟢

@Aamod-Dev Aamod-Dev left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review

This PR cannot be approved in its current state due to blocking issues (status:blocked label, merge conflicts, needs-rebase label, and/or failing CI checks). Please resolve the blocking issues and re-request review.

Once unblocked, I'm happy to re-review! 💚

@Aamod-Dev Aamod-Dev added the bug Something isn't working label Jun 21, 2026

@Aamod-Dev Aamod-Dev left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Making API timeouts configurable via environment variables is a very useful operational enhancement. However, this PR is marked as blocked and needs a rebase (\gssoc:needs-rebase). Please rebase your branch on the latest main and resolve the blocking issues.

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

Labels

bug Something isn't working gssoc:needs-rebase GSSoC 2026 level:beginner Small changes Usually isolated fixes or simple UI/text updates. mentor:Aamod007 quality:clean PR follows clean coding practices, proper formatting, documentation, and maintainability standards. status:blocked This PR is blocked due to a failing CI check. type:bug Something isn't working as expected

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Architecture: GraphQL and REST API timeouts hardcoded, not configurable for slow networks or high load

3 participants