Skip to content

Commit ef5ce9f

Browse files
keithbrinkclaude
andauthored
fix: catch OAuth token refresh timeouts in call() method (#93)
Move setupHttp() and test endpoint URL replacement inside the try-catch block to ensure connection timeouts during token refresh are caught and converted to AmznSPAConnectionTimeoutException, which job middleware already handles. Co-authored-by: Claude Haiku 4.5 <noreply@anthropic.com>
1 parent aff5c2f commit ef5ce9f

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/AmznSPAHttp.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -169,13 +169,13 @@ public function useRestrictedDataToken(): void
169169
*/
170170
private function call(string $method, string $url, array $data = [], bool $grantless = false): array|object
171171
{
172-
$this->setupHttp($this->config->getHttp(), $grantless, $url, $method);
172+
try {
173+
$this->setupHttp($this->config->getHttp(), $grantless, $url, $method);
173174

174-
if ($this->config->shouldUseTestEndpoints()) {
175-
$url = str_replace('//sellingpartnerapi', '//sandbox.sellingpartnerapi', $url);
176-
}
175+
if ($this->config->shouldUseTestEndpoints()) {
176+
$url = str_replace('//sellingpartnerapi', '//sandbox.sellingpartnerapi', $url);
177+
}
177178

178-
try {
179179
/** @var Response $response */
180180
$response = $this->http->$method($url, $data);
181181

0 commit comments

Comments
 (0)