Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ungit stopped working on Chrome 57 #887

Closed
leonadler opened this issue Mar 22, 2017 · 10 comments
Closed

Ungit stopped working on Chrome 57 #887

leonadler opened this issue Mar 22, 2017 · 10 comments

Comments

@leonadler
Copy link

leonadler commented Mar 22, 2017

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!
@bes-internal
Copy link
Contributor

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

@leonadler
Copy link
Author

leonadler commented Mar 22, 2017

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.

@guillaumedavidphd
Copy link

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.

@leonadler
Copy link
Author

leonadler commented Mar 24, 2017

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 !

@guillaumedavidphd
Copy link

NP :)

@jung-kim
Copy link
Collaborator

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

@FredrikNoren
Copy link
Owner

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

@FredrikNoren
Copy link
Owner

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

jung-kim added a commit that referenced this issue Apr 3, 2017
Fix cached promised values not resolving properly in some platforms.  #874 #878 #887
@nikolowry
Copy link

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?

@campersau campersau mentioned this issue Apr 4, 2017
@leonadler
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants