Skip to content

Feature Request: Expose response headers for rate limit handling #661

@FillipeAmaral

Description

@FillipeAmaral

Goal

Follow Azure DevOps rate limiting best practices:

"Honor the Retry-After header: If you receive it in a response, wait the specified time before sending another request. The response still returns
HTTP 200, so retry logic isn't required."

"Monitor X-RateLimit headers: If available, track X-RateLimit-Remaining and X-RateLimit-Limit to approximate how quickly you're approaching the
threshold."

Reference: https://learn.microsoft.com/en-us/azure/devops/integrate/concepts/rate-limits

Problem

  1. Response headers are lost here (ClientApiBases.ts pattern used in all generated APIs):
res = await this.rest.get<T>(url, options);
return this.formatResponse(res.result, ...);  // res.headers discarded
  1. I can't tell if the library respects these headers internally (doesn't appear to)

Note

RateLimit interface and extractRateLimitHeaders() exist but are never used.

Request

Expose response headers so users can implement proactive throttling.


If there's interest, I'm happy to open a PR. One possible approach:

  // New parallel methods in generated APIs (non-breaking)
  const response = await coreApi.getProjectsWithResponse();
  // response.result = [...]
  // response.headers = {...}
  // response.rateLimit = { remaining, limit, delay, reset }

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions