Skip to content

Commit 2545789

Browse files
committed
fix(endpoint-discovery): delete failed cache entry in blocking operations
1 parent 8fe1b54 commit 2545789

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

packages/middleware-endpoint-discovery/src/updateDiscoveredEndpointInCache.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,11 @@ export const updateDiscoveredEndpointInCache = async (
5454
resolve();
5555
})
5656
.catch((error: any) => {
57-
if (error.name === "InvalidEndpointException" || error.$metadata?.httpStatusCode === 421) {
58-
// Endpoint is invalid, delete the cache entry.
59-
endpointCache.delete(cacheKey);
60-
}
57+
// The cache entry must be deleted
58+
// because a subsequent blocking request will be stuck
59+
// in a waiting state if it sees the cache entry
60+
// but we have already flushed the request queue.
61+
endpointCache.delete(cacheKey);
6162

6263
const errorToThrow = Object.assign(
6364
new Error(

0 commit comments

Comments
 (0)