-
Notifications
You must be signed in to change notification settings - Fork 238
X-Server-Timeout header not sent when httpOptions.timeout is set without httpOptions.headers #1489
Copy link
Copy link
Open
Labels
api: vertex-aiIssues related to the Vertex AI API.Issues related to the Vertex AI API.priority: p2Moderately-important priority. Fix may not be included in next release.Moderately-important priority. Fix may not be included in next release.status:awaiting user responseissues requiring a response from the userissues requiring a response from the userstatus:staleIssues tagged for cleanup by the stale issue workflow.Issues tagged for cleanup by the stale issue workflow.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Metadata
Metadata
Assignees
Labels
api: vertex-aiIssues related to the Vertex AI API.Issues related to the Vertex AI API.priority: p2Moderately-important priority. Fix may not be included in next release.Moderately-important priority. Fix may not be included in next release.status:awaiting user responseissues requiring a response from the userissues requiring a response from the userstatus:staleIssues tagged for cleanup by the stale issue workflow.Issues tagged for cleanup by the stale issue workflow.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Description
When setting
httpOptions.timeouton agenerateContentrequest (or any request), the SDK correctly applies a client-side timeout viaAbortController, but fails to send theX-Server-Timeoutheader to the server. This means the Vertex AI backend uses its default server-side timeout (5 minutes / 300s), regardless of the client-side timeout value.Root cause
In
getHeadersInternal, theX-Server-Timeoutheader is only appended whenhttpOptions.headersis truthy:If a user passes
httpOptions: { timeout: 600000 }without aheadersproperty,httpOptions.headersisundefined, so the entire block is skipped — including theX-Server-Timeoutlogic.Expected behavior
The
X-Server-Timeoutheader should be sent wheneverhttpOptions.timeoutis set, regardless of whetherhttpOptions.headersis provided.Suggested fix
Move the
X-Server-Timeoutlogic outside thehttpOptions.headerscheck:Workaround
Pass an empty
headersobject alongsidetimeout:Reproduction
Environment
@google/genaiversion: 1.42.0