Unhandled HTTP 429 `Too Many Requests` leading to silent failure
Opened this issue · 0 comments
Summary
The TL;DR is simply that serverless-add-api-key
does not appear to correctly handle a HTTP 429 Too Many Requests
response. Making matters worse, the deployment is still marked as successful, despite the usage plans and/or API keys not being correctly created.
Details
I have encountered this when deploying a serverless app with ~50 API keys with no additional specifications:
custom:
apiKeys:
- name: key01
- name: key02
# ...
- name: key50
It would appear that serverless-add-api-key
neither throttles requests, nor handles 429 errors, resulting in the following:
| AddApiKey: Api key [redacted] already exists, skipping creation.
| AddApiKey: Usage plan [redacted]-usage-plan already exists, skipping creation.
| AddApiKey: Usage plan [redacted]-usage-plan already has api key associated with it, skipping association.
| AddApiKey: Failed to associate api key with usage plan. Error Too Many Requests
| AddApiKey: Failed to add api key the service. Error Too Many Requests
Resolution
Ideal Solution
The ideal solution would be that HTTP 429 responses are handled correctly, and the request is re-attempted after a delay (or after the suggested Retry-After: {seconds}
header).
Temporary Solution
Slowing down the for-loop would provide a simple fix, albeit not ideal in the long term.