Vindication!

Looks like I’m not just a grumpy dwarf battling against the flow. Someone else uncovering problems with AJAX’s asynchrony here.

In 99% of cases this worked fine, until I suddenly discovered nodes appearing under the wrong parent. What had happened was that the server was under more load, there were more nodes in one particular branch and the data was taking longer to return than before.

I get the feeling that for many, that is works right 99% of the time is good enough. The problem is 1% of the time it wasn’t just “not working”, it was actually providing misleading information to the user which might also load to data “corruption”, if a user was to make changes, based on that false state of the application. From my perspective that 1% means == malpractice if you deliver it to a client.

There are two solutions I know to this problem:
1. Lock the view.
2. Pass the view state to the remote method and return it along with the data.

From my angle, I’d prefer to handle this at a “transport” level. I see people implementing cool things in the UI like “faders”, “throbbers” etc. but that’s not fixing the problem, it’s just warning the user to be nervous.

The simplest solution I can think of is that Harshit recommends – only ever have one async request in progress at a time.

In Javascript that might simply mean using a single, global XMLHttpRequest object and protecting it from multiple requests using some of the techniques I mentioned before here. The next step from there might be implementing a queue onto which requests can be placed until the XMLHttpRequest object is ready to handle them, although that’s already an order of magnitude more complex and leaves some grey areas in terms of how the queue relates to the end user experience. Long term some real solutions are needed here. Meanwhile find this @ ajaxpatterns somewhat confused…

Anyway – slowly exploring the solutions which I’ll try blogging another time.

One Response to Vindication!
  1. ppionerka
    May 20, 2006 | 6:41 pm

    I like your site
    hydrocodone |