marksherman/snapshot-service

Server does not respond to xhr request, eventually timing out.

Closed this issue · 1 comments

  • Launch the server in node per instructions. (Keep it running)
  • Open client.html in chrome and open its js console.
  • Press one of the buttons and you will see the test data being received by the server in your terminal.

All of this works fine. To see the problem...

In the chrome debug console, click on Network. Notice that the xhr POST requests are either pending or failed. They consistently fail after 2 minutes, which is just a timeout. Somewhere in my server code, the server is not responding properly, causing this timeout.

screen shot 2015-12-30 at 1 54 06 pm

This issue does NOT happen if the log method is changed to the non-saving "consolelog". This isolates the problem to the "saveProject" method, which is what commits incoming data to git in the backend.

To test this, open server/rpc_modules/file.js and at the very bottom of the file, change the definition of log: to consolelog, and re-test.

module.exports = {
  //log: saveProject
  log: consolelog
};

Running the same tests with client.html, the results of the xhr calls are near-instant, as they should be.
screen shot 2015-12-30 at 1 59 00 pm

To be clear:

  • saveProject is the primary tool, which does a lot of background work committing things to git.
  • consolelog is a drop-in replacement used in debugging that simply prints the data to console.

Internally, saveProject calls another method, saveProjectToGit, which is where all the hairy git stuff is. It's all ES6 promises, where there are many system operations that need to be called in order, so the promise thens make unpalatably long chains.

I seek help in identifying where the git process is going off the rails, and I seek wisdom in ways to better handle this interface.