Monday, March 10, 2008

Working with Ajax.net - Javascript Error

I'm currently developing a project using Ajax.net and spent a few hours trying to figure out this bug that just started creaping in. When calling a specific WebService method, but not others, I would get this befuddling error. Then after I called that method and got the error, the other webservice methods would fail with the same error.

This is one of those things that scares me about some frameworks. Sure they help you speed up development when they are working but sometimes when they error out you are really screwed because they sometimes do not provide adequate error messages to help you resolve your problem.

This is the first project that I have called a webservice from javascript, and the first time I had used the ScriptService attribute on a webservice and I was impressed with the ease of how it worked. Previously I had sort of rolled my own httpRequests against blank asp pages, so I really liked the work I saved using ajax.net instead.

But then, after coming back to work on a Monday, I had started to get this error:
Sys.ArgumentTypeException: Object of type 'String' cannot be converted to type 'Function'. Parameter name: onFailure

According to FireBug, It was occuring on this line:
{name: "userContext", mayBeNull: true, optional: true}
inside the function prototype
Function._validateParams in the Sys$Net$WebServiceProxy$_invoke function of ScriptResource.axd. This is all generated code that I have absolutely no control over.

I spent several frustrated hours googling the error message and trying to figure out what was wrong.
Other people were getting the error but none really described my problem or resolved the issue. We had had some svn troubles and I thought it might have something to do with that. I wondered it maybe it had never worked on that computer because I had done a lot of it on my laptop. But after firing up the laptop, it was having the same error too. I tried changing the parameters, adding one or two bogus strings parameters to it. But nothing would give me a clue as to what was wrong.

So after creating a new function and copying things over to it and seeing it work just fine inside another method it finally hit me like a ton of bricks. The error message that I thought was telling me nothing was telling me everything. Within that block of code I had defined a string variable with the same name as my error handling method, both of them were called "error". When I tried to use error as my OnFailure function parameter, it was using the string instead.

Once that branch of code was executed, "error" was defined as a string instead of a method, because javascript doesn't have scope, and every other method that used the "error" function was now using a string instead.

My computer science professor would probably be ashamed. But I suppose a developer with 9 years of experience needs to be humbled every now and then with a freshman mistake.

Wednesday, August 8, 2007

Google Has The Answer. Err, Well, Most of the Time Anyway

I was reading a post on Web Worker Daily about underused Google tips and hacks, and was very amused at my result from trying out one of the suggestions offered by one of the commenters on the post. I should also say that if you haven't read the Hitchhiker's Guide to the Galaxy, or ever plan on it, you may want to stop reading this, or at least try not this suggestion. It might be slightly SPOILING.

The commenter had suggested:

Leif902 says;

August 8th, 2007 at 2:53 pm

Try googling “the answer to life the universe and everything”

http://www.google.com/search?q=the+answer+to+life+the+universe+and+everything

Yes that’s correct, google has the answer to life stored away in it’s index! (Now if only it knew the question…)


So I, being a big fan of THGTTG, did just that. Here was my amusing and somewhat fitting response:


I almost thought it was a joke on Google's part, so I got the screen shot. I tried it again and it wasn't, I got the desired integer. But it was a fortunate posting opportunity on my part. ;-)

Wednesday, August 1, 2007

Murphy Came a' Gunnin'... From Turkmenistan!

The company that I work for, like most companies, owns a domain or two. Some are strictly for marketing, some are preemptive registrations, such as the domains that relate to our products, and then there are some that we use to put our applications on. We had been using RegisterFly, which you may or may not know was caught up in a scandal where the corporate board fired the CEO Kevin Medina for spending too much company money on hookers and liposuction, but not before getting and changing the root passwords to some system of theirs that left complete control of half of the domains registered with them in the hands of said fired guy.

My company took proactive steps, and we moved all of their registrations to GoDaddy, except as Murphy would have it, this critical one that is hosting our web applications. Somehow (I suspect Mr. Asshat CEO in a quest for liposuction and hooker money) this one, most critical domain landed up in the hands of some guy with "SJ Domains" who says his address is in Turkministan, and his email is in the UK, and his name is supposedly "Rishar Maas". The most I could find out about this guy is that it looks like he trades a lot in Russian domains and he is pretty good about covering his tracks in this low level hoodery that he is involved in.

This happened even though our registration never lapsed. As a matter of fact it still wouldn't have lapsed at the time of this writing. But the Whois says that he is the registered owner now of a domain that we have owned since the turn of the friggin' century (sounds a lot longer than 7 years). But at the time of this discovery it was still pointing at our DNS servers, so everything is still working.

So we of course immediately start to move all of our webapps off of this domain and use another one. Of course, we might as well try to get this domain back. So we contact him. The asshole
immediately sees an opportunity for extortion and changes the DNS servers to point to some parking site he uses and he puts our domain up for auction. We contest the auction, which puts a stop to it, and we tell him this is our domain and nobody gives a crap about it besides us, and while it's worth a quick couple of hundred bucks to us right now to get it back, in a few days we won't give a shit about it because we were well on the way of not needing it.

So Mr. Rishar Asshole Maas tells us he wants more than a thousand dollars for it. We tell him to eat shit and die unless he can somehow bring himself to take $500 for being a lowlife piece of shit thief and being the lowlife piece of shit that Rishar Maas obviously is, he took it. He's probably over in London with Kevin Medina right now blowing it all on whores (or little boys or most likely, given that he is a Turkmenistanian, sheep).

So this first substantive post is in 'honor' of Rishar Maas or the alias owner known as such (Kevin Medina perhaps?) - Domain Thief and All Around Asshole.

First Post: Mission Statement

I created this blog as a place to put my tech related stuff. I'm sure the three or four people who might read Swamproot could do without the occasional tech story I might put there (which I only did so that I could keep my notes on that particular subject online).

So here will be the occasional chronicles of a plumber of the internet tubes, and rant-o-rific musings of one who has come to realize that working in IT is an continuous exercise in keeping sane while interacting with the chaos that is software, hardware and business.

An experienced IT person can tell you that what they do might as well be Voodoo, given the somewhat tenuous relationship between cause and effect that can at times be quite hard to pin down. So I thought I would write a blog about my experiences in that regard.

I am, like many programmers and engineers, a big fan of the attributed wisdom of Murphy and his laws. One day while searching for a phrase that would best describe one of these "experiences" I came up with "Murphy's Monkey Wrench" getting thrown in the machine. So I thought "That would make a good blog title". So, thanks to Blogger, within 2 minutes I had it.

So, that is the purpose of this blog. Hopefully, I'll have a little more to say later, about actual Murphy Monkey Wrenches.

Swamproot