Endless calls to API
The frontend should not end up in an endless loop. This is a case when a user opened a link to the Dataset from their Dashboard, but they don't have access (it's not published).
Backend reports:
2019-06-07T14:43:14.437730932Z 14:43:14,437 qtp2027961269-16 WARN o.g.s.a.ApiExceptionHandler:97 - Authentication is required GET http://api.genesys-pgr.org/api/v1/dataset/accessions/5ff5ea92-2ec6-4e44-8c7a-a079a21c6a27
2019-06-07T14:43:14.647047194Z 14:43:14,646 qtp2027961269-9 WARN o.g.s.a.ApiExceptionHandler:97 - Authentication is required GET http://api.genesys-pgr.org/api/v1/dataset/accessions/5ff5ea92-2ec6-4e44-8c7a-a079a21c6a27
2019-06-07T14:43:14.851856864Z 14:43:14,851 qtp2027961269-16 WARN o.g.s.a.ApiExceptionHandler:97 - Authentication is required GET http://api.genesys-pgr.org/api/v1/dataset/accessions/5ff5ea92-2ec6-4e44-8c7a-a079a21c6a27
2019-06-07T14:43:15.047369335Z 14:43:15,046 qtp2027961269-9 WARN o.g.s.a.ApiExceptionHandler:97 - Authentication is required GET http://api.genesys-pgr.org/api/v1/dataset/5ff5ea92-2ec6-4e44-8c7a-a079a21c6a27
2019-06-07T14:43:15.256079305Z 14:43:15,255 qtp2027961269-16 WARN o.g.s.a.ApiExceptionHandler:97 - Authentication is required GET http://api.genesys-pgr.org/api/v1/dataset/5ff5ea92-2ec6-4e44-8c7a-a079a21c6a27
2019-06-07T14:43:15.454463881Z 14:43:15,454 qtp2027961269-16 WARN o.g.s.a.ApiExceptionHandler:97 - Authentication is required GET http://api.genesys-pgr.org/api/v1/dataset/accessions/5ff5ea92-2ec6-4e44-8c7a-a079a21c6a27
2019-06-07T14:43:15.661764267Z 14:43:15,661 qtp2027961269-9 WARN o.g.s.a.ApiExceptionHandler:97 - Authentication is required GET http://api.genesys-pgr.org/api/v1/dataset/5ff5ea92-2ec6-4e44-8c7a-a079a21c6a27
2019-06-07T14:43:15.877504323Z 14:43:15,877 qtp2027961269-10 WARN o.g.s.a.ApiExceptionHandler:97 - Authentication is required GET http://api.genesys-pgr.org/api/v1/dataset/5ff5ea92-2ec6-4e44-8c7a-a079a21c6a27
2019-06-07T14:43:16.058052593Z 14:43:16,057 qtp2027961269-9 WARN o.g.s.a.ApiExceptionHandler:97 - Authentication is required GET http://api.genesys-pgr.org/api/v1/dataset/5ff5ea92-2ec6-4e44-8c7a-a079a21c6a27
2019-06-07T14:43:16.105639864Z 14:43:16,105 qtp2027961269-16 WARN o.g.s.a.ApiExceptionHandler:97 - Authentication is required GET http://api.genesys-pgr.org/api/v1/dataset/5ff5ea92-2ec6-4e44-8c7a-a079a21c6a27
2019-06-07T14:43:16.298065563Z 14:43:16,297 qtp2027961269-9 WARN o.g.s.a.ApiExceptionHandler:97 - Authentication is required GET http://api.genesys-pgr.org/api/v1/dataset/5ff5ea92-2ec6-4e44-8c7a-a079a21c6a27
2019-06-07T14:43:16.483461627Z 14:43:16,483 qtp2027961269-16 WARN o.g.s.a.ApiExceptionHandler:97 - Authentication is required GET http://api.genesys-pgr.org/api/v1/dataset/5ff5ea92-2ec6-4e44-8c7a-a079a21c6a27
2019-06-07T14:43:16.673460381Z 14:43:16,673 qtp2027961269-9 WARN o.g.s.a.ApiExceptionHandler:97 - Authentication is required GET http://api.genesys-pgr.org/api/v1/dataset/5ff5ea92-2ec6-4e44-8c7a-a079a21c6a27
2019-06-07T14:43:16.865991532Z 14:43:16,865 qtp2027961269-16 WARN o.g.s.a.ApiExceptionHandler:97 - Authentication is required GET http://api.genesys-pgr.org/api/v1/dataset/5ff5ea92-2ec6-4e44-8c7a-a079a21c6a27
2019-06-07T14:43:17.054762272Z 14:43:17,054 qtp2027961269-9 WARN o.g.s.a.ApiExceptionHandler:97 - Authentication is required GET http://api.genesys-pgr.org/api/v1/dataset/5ff5ea92-2ec6-4e44-8c7a-a079a21c6a27
2019-06-07T14:43:17.249567005Z 14:43:17,249 qtp2027961269-16 WARN o.g.s.a.ApiExceptionHandler:97 - Authentication is required GET http://api.genesys-pgr.org/api/v1/dataset/5ff5ea92-2ec6-4e44-8c7a-a079a21c6a27
2019-06-07T14:43:17.437204223Z 14:43:17,436 qtp2027961269-9 WARN o.g.s.a.ApiExceptionHandler:97 - Authentication is required GET http://api.genesys-pgr.org/api/v1/dataset/5ff5ea92-2ec6-4e44-8c7a-a079a21c6a27
2019-06-07T14:43:17.632148846Z 14:43:17,631 qtp2027961269-16 WARN o.g.s.a.ApiExceptionHandler:97 - Authentication is required GET http://api.genesys-pgr.org/api/v1/dataset/5ff5ea92-2ec6-4e44-8c7a-a079a21c6a27
2019-06-07T14:43:17.826279192Z 14:43:17,825 qtp2027961269-9 WARN o.g.s.a.ApiExceptionHandler:97 - Authentication is required GET http://api.genesys-pgr.org/api/v1/dataset/5ff5ea92-2ec6-4e44-8c7a-a079a21c6a27
2019-06-07T14:43:18.016622228Z 14:43:18,016 qtp2027961269-16 WARN o.g.s.a.ApiExceptionHandler:97 - Authentication is required GET http://api.genesys-pgr.org/api/v1/dataset/5ff5ea92-2ec6-4e44-8c7a-a079a21c6a27
2019-06-07T14:43:18.214441526Z 14:43:18,214 qtp2027961269-9 WARN o.g.s.a.ApiExceptionHandler:97 - Authentication is required GET http://api.genesys-pgr.org/api/v1/dataset/5ff5ea92-2ec6-4e44-8c7a-a079a21c6a27
2
This happens on any page if the server responds with 401 Access denied
and we need a solution.
The key problem is that we test the conditions for reload in both componentWillMount
and componentWillReceiveProps
. This is because in SSR we already have the data in Redux state and we don't need to reload data in componentWillMount
, while in development we have to load here.
SSR needs
only execute once (no loop). But this still writes the (error) state that is sent to the client.
Idea 1
Write to component state
that we're received new properties and started loading the data. In componentWillReceiveProps
we can check if we did the call for the same properties (e.g. for uuid
) and avoid the call.
Update: this still doesn't work because Redux state ApiCall will contain the error response and there's no component state to compare to.
Other ideas?
I'm out of ideas. Suggestions, please.