Skip to content

fix: allow per-connection refresh lead time override via providerSpecificData.refreshLeadMs (closes #593)#605

Open
anuragg-saxenaa wants to merge 1 commit intodecolua:masterfrom
anuragg-saxenaa:fix/issue-593-timeout-renewal
Open

fix: allow per-connection refresh lead time override via providerSpecificData.refreshLeadMs (closes #593)#605
anuragg-saxenaa wants to merge 1 commit intodecolua:masterfrom
anuragg-saxenaa:fix/issue-593-timeout-renewal

Conversation

@anuragg-saxenaa
Copy link
Copy Markdown
Contributor

Summary

Issue #593 requested the ability to manually configure the Provider Connection timeout renewal time, as the current hardcoded renewal interval was too short.

Fix

Modified getRefreshLeadMs() in open-sse/services/tokenRefresh.js to accept an optional per-connection override via providerSpecificData.refreshLeadMs:

// Before
export function getRefreshLeadMs(provider) {
  return REFRESH_LEAD_MS[provider] || TOKEN_EXPIRY_BUFFER_MS;
}

// After
export function getRefreshLeadMs(provider, providerSpecificData) {
  if (providerSpecificData?.refreshLeadMs != null) {
    return providerSpecificData.refreshLeadMs;
  }
  return REFRESH_LEAD_MS[provider] || TOKEN_EXPIRY_BUFFER_MS;
}

The caller in src/sse/services/tokenRefresh.js (checkAndRefreshToken) now passes creds.providerSpecificData so per-connection overrides take effect.

Usage

To set a custom renewal lead time for a connection, set providerSpecificData.refreshLeadMs (in milliseconds) on the connection. For example, to extend the renewal lead to 30 minutes:

providerSpecificData: { refreshLeadMs: 30 * 60 * 1000 }

If not set, defaults to the provider-specific defaults from REFRESH_LEAD_MS or the global TOKEN_EXPIRY_BUFFER_MS (5 minutes).

Closes #593

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.

Minor feature: Add attribute to set Provider Connection timeout renewal

1 participant