mcrowe / soulmate.js

A jQuery front-end for the soulmate auto-suggestion gem
MIT License
121 stars 18 forks source link

Autocomplete suggestions get aborted/canceled #12

Closed Joseph-N closed 10 years ago

Joseph-N commented 10 years ago

I have a small demo app hosted on heroku that uses soulmate.js for autocompletion. This app works perfectly on development but the autocomplete never happens on production.

On production I get this errors on my browser console

Google Chrome (Version 35.0.1916.153)

image

Mozilla Firefox (29.0.1)

image

Any help on how to fix this? Thanks

mcrowe commented 10 years ago

Hmmm... I'm still not able to recreate the problem (on FF 29 and Chrome 36). There aren't many terms that return actual results from the soulmate backend you're pointing to. It also seems pretty slow to respond (~300ms which is way higher than usual for soulmate). It's possible that is causing some weird timing issues, although I'm not sure how. If you type "go" and wait for half a second, do you not get a number of results?

The "errors" you're seeing are actually expected even when everything is working properly. Those are canceled XHR events that were sent before you typed the last character. Every time you type a character, the previous events are canceled so that you only get results matching what you've currently typed in. For example, if I type "go", an XHR request is sent to get results. If I type "r" right afterwards, that "go" request is canceled because I don't want those results anymore, and instead wait for the "gor" request to complete.

Joseph-N commented 10 years ago

Aah thanks for shedding some light on that, that was really helpful. On the earlier site I had posted, waiting for around half a second seemed to bring back some results. But the thing is, sometimes its working sometimes its not. I have another site, downloadrare.com also using soulmate. I have, for instance, a tv show called breaking bad. Typing in the first word breaking and waiting for even longer than 2 secs, I still don't have any results. But the requested url actually has data

screenshot from 2014-07-21 22 41 13

Does this work on your end?

mcrowe commented 10 years ago

Hi Joseph. Sorry to say that this site seems to be working just fine on my end. Tried Chrome, Firefox, and Safari. I'm not sure what to suggest for debugging the issue on your end. Perhaps you can throw some console.logs into the soulmate codebase to see what it is doing with the results you aren't seeing. Is the success callback getting called?

Joseph-N commented 10 years ago

Hi @mcrowe . At last I was able to fix the problem. My issue was that I was using a textbox with the name search. Many browsers have a browser's built-in auto-complete feature that gets in the way of soulmate's js autocompletion. Setting autocomplete off for the text field did the trick. Thank you for your help! :thumbsup:

mcrowe commented 10 years ago

Ahhhh.... Glad to hear it @Joseph-N . Thanks a lot for posting the solution here. Hopefully it will help someone else.

manuelloriat commented 10 years ago

Thanks @Joseph-N! I'm facing the same issue.. I'll give it a try :) BTW, how did you figured it out? and if this is something related to the input field, why you think it works on development as expected but not on stage or production?

nurbs999 commented 8 years ago

I just ran into the same issue. But even autocomplete off did not help. Any other suggestions?

manuelloriat commented 8 years ago

Can you do some benchmark to the server method? I ran into the issue that my request was using more than 2s and it was causing the cancelled status.

nurbs999 commented 8 years ago

Thanks! You are absolutely right. I'm polluting the database with some test data. That causes the request to take more than 1s sometimes. I set the timeout to 3000ms, which seems enough.

Suggestion: Please add the timeout option to the README