Search code examples
ruby-on-railsherokuvuejs2ruby-on-rails-5

Heroku Error code=H27 desc="Client Request Interrupted" method=POST USING RAILS Server-side,Vue front-end


I just spent a few days of digging on logs, changing repositories and lots of frustration. I'm using a Rails API hosted on Heroku and a Vue front-end app also hosted on Heroku.

On authentication POST request from the Vue application to the Rails API, the heroku H27 error occurs.

I've read this article: Client Request Interrupted in Heroku and all the other related articles, yet I've haven't seen any concrete answer.

this.$http.post('/authenticate',{'email':this.user.email,'password':this.user.password},{headers:
    {'Access-Control-Allow-Origin': '*'}}
  ).then((result)=>{
    localStorage.setItem('Authorization',result.data.auth_token);
    this.$http.defaults.headers.common['Authorization'] = localStorage.Authorization;
    this.$router.push('/');
  })
  .catch(error => {
    console.log(error.response);
    alert("Wrong cradentials, if you dont have an account - sign in");
  });

sock=client at=warning code=H27 desc="Client Request Interrupted" method=POST path="/authenticate" host=api-url request_id=9c3016cd-910a-4sd1f-9020-e0asd280e8 fwd="ip" dyno=web.1 connect=2ms service=289ms status=499 bytes= protocol=https

Sometimes the request lands successfully and everything works fine, and sometimes not, about 50\50.

If I log-in then log-out, then again log-in most of the time the problem pop out. Sometimes it occurs right away on the first try and on the second it works fine. I've tried changing the parameters being sent and tried string interpolation variations without any success.

To relate, after the POST request is sent with the user credentials, Rails runs the authenticate methods which confirms the user and sends back an auth token as a string.


Solution

  • The cause - collision of multiple requests to the server side. apparently I've forgot to prevent the submit button from it's default operation. and therefor while the Js sends ajax request, the form which the submit button was on sends It's own request. Now it was matters of delay, when the js request came first it got interrupted by the form request.