normativeai / frontend

GNU General Public License v3.0
5 stars 3 forks source link

Calling independence check twice fails with Error: undefined #29

Closed shaolintl closed 5 years ago

shaolintl commented 5 years ago

Using the rome account and over the Rome regulation - annot. legislation. When I try to run independence check on the norms which were auto generated. There is no problem the first time and for all repeating attempts (for other norms as well), I get Error: undefined. When refreshing the page, I can again use it once without a problem.

1) I am not sure why it happens only on the second and later attempts. I do not log any request on the backend. 2) Such error seems to happen when you look for an error on an API call and it doesnt exist. Maybe the name of the property is different? Can you tell me which one you use there?

lex-lex commented 5 years ago

On the second click, the HTTP request returns an error with headers

HTTP/1.1 502 Bad Gateway
Date: Tue, 11 Jun 2019 23:24:53 GMT
Content-Type: text/html
Content-Length: 584
Connection: keep-alive
Strict-Transport-Security: max-age=15552000
X-XSS-Protection: 1; mode=block
X-Frame-Options: SAMEORIGIN
X-Content-Type-Options: nosniff

and payload

<html>
<head><title>502 Bad Gateway</title></head>
<body bgcolor="white">
<center><h1>502 Bad Gateway</h1></center>
<hr><center>nginx/1.14.0 (Ubuntu)</center>
</body>
</html>
<!-- a padding to disable MSIE and Chrome friendly error page -->
<!-- a padding to disable MSIE and Chrome friendly error page -->
<!-- a padding to disable MSIE and Chrome friendly error page -->
<!-- a padding to disable MSIE and Chrome friendly error page -->
<!-- a padding to disable MSIE and Chrome friendly error page -->
<!-- a padding to disable MSIE and Chrome friendly error page -->

I have no idea what's happening there. The first and the second request are quite similar, both request GET /api/theories/5cfa3840260d6043a845e8d0/independent/5cff75237369801965e8f569 HTTP/1.1.

Details: (first request)

GET /api/theories/5cfa3840260d6043a845e8d0/independent/5cff75237369801965e8f569 HTTP/1.1
Host: nai.uni.lu
Connection: keep-alive
Accept: application/json, text/plain, */*
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyIjp7Il9pZCI6IjVjOGNkNGNmMGM0YTY3NjIzNDYyZDkxMCIsImVtYWlsIjoicm9tZUBmb3Jtcy5uYWkifSwiaWF0IjoxNTU0ODMyOTUyfQ.blsqonoMpBjCFeTxw50bEE60oP43Kd2KoRTVtOjxAWg
User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.181 Safari/537.36
Accept-Encoding: gzip, deflate, br
Accept-Language: en-US,en;q=0.9,de;q=0.8
Cookie: _ga=GA1.2.2080909307.1515521488; LBServer=604172298.20480.0000; TS0120b154=0152bfb4c5ab293cb18847ceae41ac678a1f4e7ac38165ab0b2a512adbab18d80e980027d2993a39a2a6ea03be641c431e2b56c080ae3a031f512383a15b5aa692541f63e0; TS01c9476c=0152bfb4c562777708cbca35ae63e57e957eef5e651b1870b388dbde391e640f65b09057dc705b9f5184547e8c05d5faa7bc1798e5
If-None-Match: W/"1d-PNOtrp357QN7s+SgJieKxYBQN60"

second request:

GET /api/theories/5cfa3840260d6043a845e8d0/independent/5cff75237369801965e8f569 HTTP/1.1
Host: nai.uni.lu
Connection: keep-alive
Accept: application/json, text/plain, */*
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyIjp7Il9pZCI6IjVjOGNkNGNmMGM0YTY3NjIzNDYyZDkxMCIsImVtYWlsIjoicm9tZUBmb3Jtcy5uYWkifSwiaWF0IjoxNTU0ODMyOTUyfQ.blsqonoMpBjCFeTxw50bEE60oP43Kd2KoRTVtOjxAWg
User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.181 Safari/537.36
Accept-Encoding: gzip, deflate, br
Accept-Language: en-US,en;q=0.9,de;q=0.8
Cookie: _ga=GA1.2.2080909307.1515521488; LBServer=604172298.20480.0000; TS0120b154=0152bfb4c5ab293cb18847ceae41ac678a1f4e7ac38165ab0b2a512adbab18d80e980027d2993a39a2a6ea03be641c431e2b56c080ae3a031f512383a15b5aa692541f63e0; TS01c9476c=0152bfb4c562777708cbca35ae63e57e957eef5e651b1870b388dbde391e640f65b09057dc705b9f5184547e8c05d5faa7bc1798e5

The only change is the last line (If-None-Match), do you know what that is?

shaolintl commented 5 years ago

The error seems to be with server side caching: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/If-None-Match

I will try to add more debug info.

shaolintl commented 5 years ago

I also found that: https://stackoverflow.com/questions/43818967/502-bad-gateway-error-for-my-server-running-with-node-js-on-nginx-proxy

shaolintl commented 5 years ago

ok, I think I found the problem. The server crashes because of some problem and you get 502 Bad Gateway. When refreshing the page it somehow solves the problem. I will solve it on my side but it may be interesting to investigate why refreshing solves the problem and maybe also display a correct message such as "An unexpected server error has occurred, please try again in a few minutes and if the problem does not resolve, report it on https://github.com/normativeai/backend/issues".