ewanbrinkman / sfu-course-api-wrapper

An asynchronous TypeScript wrapper for SFU's course API.
MIT License
1 stars 0 forks source link

SFU API returns 404 error when spammed #31

Closed ewanbrinkman closed 4 hours ago

ewanbrinkman commented 8 hours ago

If the API receives many requests at once, it will return a 404 error with content {"errorMessage":"Invalid Query String or Object does not exist."}. This same exact error is returned when requesting something that actually does not exist, for example: https://www.sfu.ca/bin/wcm/course-outlines?1910.

Therefore, when a 404 error is received, it is unknown if the target actually does not exist, or if the API is currently overloaded.

ewanbrinkman commented 8 hours ago

A possible solution could be to not trust a 404 error at first. If a 404 error happens, keep retrying until apiConfig.requestRetry.maxAttempts is reached. If the API is still overloaded the entire time until apiConfig.requestRetry.maxAttempts is reached, this can be an issue, since this wrapper will say the target does not exist when it actually does. So, could instead never trust 404 errors at all even. This issue will be updated with what solution is chosen in the end

ewanbrinkman commented 4 hours ago

If a 404 error is received, it will be treated as the API being spammed. If once the maximum number of retry attempts is reached, and the error is a 404 error, then the 404 error will finally be thrown.