3xx http codes should be treated as errors
I found out, that during saving documents, the documents weren't saved, even no error was thrown.
Infrastructure:
Arango database is hosted behind the nginx load balancer. Nginx issues certificates and forces https by redirection.
Current behavior:
When arangojs receives 308 response, it doesn't throw an error, even the request hasn't been fulfilled. This behavior is really dangerous because it is easily missed.
Expected behavior
The client should throw an error.
Shouldn't it actually follow the redirects?
It should, but the error is better than nothing and it is easier to implement. The use case that someone wants to redirect database requests is improbable.
So it should be implemented, or it should throw an error that it isn't supported.
This depends. When a Foxx service responds with a redirect, that would likely not be an error but entirely expected. Throwing an error in that case by default would be bad.
In your case the proxy sending a redirect also isn't strictly an error and the expected behavior would probably be to follow that redirect in that case.
The correct approach IMO would be to add an option maxRedirects like request.js does (although it sets the default to 10 which may be unreasonably high for arangojs) and follow redirects by default. Hitting the limit would require throwing a specific error developers could recognise.