Skip to content

chore: Modify global timeouts to configurable#106

Open
tirumerla wants to merge 1 commit intomainfrom
configurable-timeouts
Open

chore: Modify global timeouts to configurable#106
tirumerla wants to merge 1 commit intomainfrom
configurable-timeouts

Conversation

@tirumerla
Copy link
Contributor

@tirumerla tirumerla commented Mar 11, 2026

  • Add fkexibility to change global timeout & polling timeout

Summary by CodeRabbit

  • New Features
    • Added configurable timeout settings for submission operations via PLUGIN_GLOBAL_TIMEOUT_MS and PLUGIN_POLLING_TIMEOUT_MS environment variables.
    • Submission requests now respect custom timeout configurations with sensible defaults (30 seconds global, 25 seconds polling).

Copilot AI review requested due to automatic review settings March 11, 2026 04:30
@coderabbitai
Copy link

coderabbitai bot commented Mar 11, 2026

Walkthrough

The PR introduces configurable timeout settings for transaction submissions by adding globalTimeoutMs and pollingTimeoutMs fields to the channel configuration, renaming related constants for clarity, and threading the configuration through the submission handler and submission logic to dynamically override default timeout values.

Changes

Cohort / File(s) Summary
Configuration and Constants
src/plugin/config.ts, src/plugin/constants.ts
Added globalTimeoutMs and pollingTimeoutMs fields to ChannelAccountsConfig with environment variable loading; renamed TIMEOUT.GLOBAL_TIMEOUT_MS to DEFAULT_GLOBAL_TIMEOUT_MS and POLLING.TIMEOUT_MS to DEFAULT_TIMEOUT_MS for semantic clarity.
Submission Flow
src/plugin/handler.ts, src/plugin/submit.ts
Extended submitWithFeeBumpAndWait signature to accept optional config parameter; threaded ctx.config through handler calls to enable dynamic timeout calculation using configured values with fallbacks to new defaults.
Test Updates
test/submit-timeout.test.ts
Updated constant references from old names (GLOBAL_TIMEOUT_MS, TIMEOUT_MS) to new names (DEFAULT_GLOBAL_TIMEOUT_MS, DEFAULT_TIMEOUT_MS) in timeout validation tests.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

Suggested reviewers

  • collins-w
  • zeljkoX

Poem

🐰 Configurable timeouts, what a delight!
No more defaults cast in stone so tight,
Handler threads config through submission's dance,
Timeouts now flex at each transaction's chance,
Dynamic waits—the system's enhanced! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 22.22% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title describes making timeouts configurable, which aligns with the PR's main objective of adding configuration flexibility for global and polling timeouts across multiple files.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch configurable-timeouts

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
test/submit-timeout.test.ts (1)

25-93: Consider adding tests for config-based timeout overrides.

The existing tests verify default timeout behavior. Consider adding test cases that pass the new config parameter with custom globalTimeoutMs and pollingTimeoutMs values to ensure the override mechanism works as expected.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@test/submit-timeout.test.ts` around lines 25 - 93, Add unit tests that
exercise the config-based timeout overrides for submitWithFeeBumpAndWait: update
or add tests using makeMocks() to call submitWithFeeBumpAndWait with a
third/fifth (as appropriate) config argument containing custom globalTimeoutMs
and pollingTimeoutMs values, then assert transactionWait was called with
opts.timeout reflecting pollingTimeoutMs (capped by the computed remaining time)
and that the immediate-reject cases respect a reduced globalTimeoutMs (i.e.,
when elapsed >= custom globalTimeoutMs - TIMEOUT.BUFFER_MS it throws
WAIT_TIMEOUT and transactionWait is not called); reference
submitWithFeeBumpAndWait, makeMocks, TIMEOUT and POLLING constants to locate
where to pass and validate these overrides.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@test/submit-timeout.test.ts`:
- Around line 25-93: Add unit tests that exercise the config-based timeout
overrides for submitWithFeeBumpAndWait: update or add tests using makeMocks() to
call submitWithFeeBumpAndWait with a third/fifth (as appropriate) config
argument containing custom globalTimeoutMs and pollingTimeoutMs values, then
assert transactionWait was called with opts.timeout reflecting pollingTimeoutMs
(capped by the computed remaining time) and that the immediate-reject cases
respect a reduced globalTimeoutMs (i.e., when elapsed >= custom globalTimeoutMs
- TIMEOUT.BUFFER_MS it throws WAIT_TIMEOUT and transactionWait is not called);
reference submitWithFeeBumpAndWait, makeMocks, TIMEOUT and POLLING constants to
locate where to pass and validate these overrides.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 32ea66d7-7b37-45de-a0bb-e0af0a0a72c6

📥 Commits

Reviewing files that changed from the base of the PR and between e4623f0 and 2732720.

⛔ Files ignored due to path filters (1)
  • .DS_Store is excluded by !**/.DS_Store
📒 Files selected for processing (5)
  • src/plugin/config.ts
  • src/plugin/constants.ts
  • src/plugin/handler.ts
  • src/plugin/submit.ts
  • test/submit-timeout.test.ts

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR makes the plugin’s global submission timeout budget and transaction polling timeout configurable via the loaded plugin config (with defaults preserved), and updates the timeout-related unit test accordingly.

Changes:

  • Rename timeout constants to DEFAULT_* and thread configurable timeout values through config.
  • Update submitWithFeeBumpAndWait to compute timeouts using config overrides when provided.
  • Update handler to pass ctx.config through to submission/wait logic.

Reviewed changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
test/submit-timeout.test.ts Updates assertions to match renamed default timeout constants.
src/plugin/submit.ts Adds optional config overrides for global/polling timeouts when computing transactionWait timeout.
src/plugin/handler.ts Passes loaded config into submitWithFeeBumpAndWait.
src/plugin/constants.ts Renames timeout constants to DEFAULT_GLOBAL_TIMEOUT_MS / DEFAULT_TIMEOUT_MS.
src/plugin/config.ts Adds env parsing + config fields for globalTimeoutMs and pollingTimeoutMs.
.DS_Store Adds an OS metadata file (should not be committed).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

PluginAPI,
} from '@openzeppelin/relayer-sdk';
import { HTTP_STATUS, TIMEOUT, POLLING } from './constants';
import { ChannelAccountsConfig } from './config';
Copy link

Copilot AI Mar 11, 2026

Choose a reason for hiding this comment

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

ChannelAccountsConfig is only used as a type here. Use a type-only import (import type) to avoid emitting an unnecessary runtime dependency and to match the existing pattern in this codebase (e.g. handler.ts / management.ts use import type { ChannelAccountsConfig }).

Suggested change
import { ChannelAccountsConfig } from './config';
import type { ChannelAccountsConfig } from './config';

Copilot uses AI. Check for mistakes.
Comment on lines +108 to +111
const globalTimeout = config?.globalTimeoutMs ?? TIMEOUT.DEFAULT_GLOBAL_TIMEOUT_MS;
const pollingTimeout = config?.pollingTimeoutMs ?? POLLING.DEFAULT_TIMEOUT_MS;
const elapsedMs = Date.now() - startTime;
const remainingMs = TIMEOUT.GLOBAL_TIMEOUT_MS - TIMEOUT.BUFFER_MS - elapsedMs;
const remainingMs = globalTimeout - TIMEOUT.BUFFER_MS - elapsedMs;
Copy link

Copilot AI Mar 11, 2026

Choose a reason for hiding this comment

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

New behavior: globalTimeoutMs / pollingTimeoutMs can override the default timeouts, but test/submit-timeout.test.ts only covers the default path. Add a test that passes a custom config to submitWithFeeBumpAndWait and asserts the computed transactionWait timeout reflects those overrides.

Copilot uses AI. Check for mistakes.
Comment on lines +141 to +153
function parseGlobalTimeoutMs(): number {
const raw = process.env.PLUGIN_GLOBAL_TIMEOUT_MS;
if (!raw) return TIMEOUT.DEFAULT_GLOBAL_TIMEOUT_MS;
const n = Number(raw);
return Number.isFinite(n) && n > 0 ? Math.floor(n) : TIMEOUT.DEFAULT_GLOBAL_TIMEOUT_MS;
}

function parsePollingTimeoutMs(): number {
const raw = process.env.PLUGIN_POLLING_TIMEOUT_MS;
if (!raw) return POLLING.DEFAULT_TIMEOUT_MS;
const n = Number(raw);
return Number.isFinite(n) && n > 0 ? Math.floor(n) : POLLING.DEFAULT_TIMEOUT_MS;
}
Copy link

Copilot AI Mar 11, 2026

Choose a reason for hiding this comment

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

PLUGIN_GLOBAL_TIMEOUT_MS / PLUGIN_POLLING_TIMEOUT_MS parsing is new and isn’t covered by existing test/config.test.ts cases. Add tests for defaulting, valid numeric values (including flooring), and invalid/non-positive values falling back to defaults.

Copilot uses AI. Check for mistakes.
Copy link
Contributor

@zeljkoX zeljkoX left a comment

Choose a reason for hiding this comment

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

LGTM

Seems like few tests missing and commited .DS_Store

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.

4 participants