FredrikNoren/ungit

Ungit stopped working on Chrome 57

leonadler opened this issue · 10 comments

The recent version of Chrome gives me the "Whooops - Something went wrong, reload the page to start over." message.
The same server & directory works in Firefox. Chrome private mode does not fix it either.
Accessing both via localhost or 127.0.0.1 do not work in chrome, both work in Firefox.

Versions:

  • OS: Arch Linux
  • chrome: 57.0.2987.110 (64-bit)
  • firefox: 52.0 (64-bit)
  • node: 6.10.1
  • npm: 4.4.1
  • ungit: 1.1.11

My server.log (via ungit --logRESTRequests --logGitCommands --logGitOutput)
Chrome's browser console output.
Any other Information I can provide?

by the way: very nice work on ungit!

Can't confirm on same chrome version on linux.

From your console output:

server.js:174 Unhandled Promise ERROR:  Object {errorCode: "cross-domain-error", error: Object} Promise {_bitField: 18087936, _fulfillmentHandler0: Object, _rejectionHandler0: undefined, _promise0: undefined, _receiver0: undefined…}

cast @codingtwinky

The error thrown seems to be caused by an XHR returning status 0 for GET /api/log in server.js:

Server.prototype._httpJsonRequest = function(request, callback) {
  var httpRequest = new XMLHttpRequest();
  httpRequest.onreadystatechange = function() {
    // It seems like you can get both readyState == 0, and readyState == 4 && status == 0 when you lose connection to the server
    if (httpRequest.readyState === 0) {
      callback({ error: 'connection-lost' });
    } else if (httpRequest.readyState === 4) {
      var body;
      try {
        body = JSON.parse(httpRequest.responseText);
      } catch(ex) { body = null; }
      if (httpRequest.status == 0) {
      	callback({ error: 'connection-lost' });  // <--- error is thrown here
      }
      else if (httpRequest.status != 200) callback({ status: httpRequest.status, body: body, httpRequest: httpRequest });
      else callback(null, body);
    }
  }
  var url = request.url;
  if (request.query) {
    url += '?' + this._queryToString(request.query);
  }
  httpRequest.open(request.method, url, true);
  httpRequest.setRequestHeader('Accept', 'application/json');
  if (request.body) {
    httpRequest.setRequestHeader('Content-Type', 'application/json');
    httpRequest.send(JSON.stringify(request.body));
  } else {
    httpRequest.send(null);
  }
}

Properties of request:

{
    "method": "GET",
    "url": "/api/log",
    "query": {
        "path": "/home/leon/Development/immutablets",
        "limit": 25,
        "skip": 0,
        "socketId": 0
    }
}

Opening the endpoint directly in a new tab returns HTTP 200 and a proper JSON body.

I can reproduce it on every run, if I can provide any more information to narrow it down, let me know.

I had the same issue. One of my ad blockers was breaking ungit: uBlock Origin. After disabling it on localhost everything went back to normal.

Can confirm, after unblocking localhost via uBlock origin ungit works like a charm again.
I did not think of this solution since I had "localhost" in uBlocks whitelist - but it needs a separate entry for "localhost:8448"...

Thank you, @guillaumedavidphd !

@FredrikNoren do you think this should be documented in the readme?

@codingtwinky hm guess it doesn't hurt to link to this issue under known issues

hm actually, maybe what we should do is have a special error message when the server can't be reached? (Rather than the default one). Could say something like "The ungit host program cannot be reached. Make sure it's running, and make sure you're system is configured to allow localhost connections" (with maybe a link to the readme).

I don't have time to implement right now but if anyone's interested that might help other people to navigate this issue

The codebase is rather large, so I didn't dig prior to this suggestion - but couldn't the appropriate CORS headers be added to the ungit server?

This was not caused by CORS, but by an adblocker preventing an endpoint from loading, resulting in an HTTP status of 0 and an xhr.readyState of 0.