I had checked the documentation when you mentioned checking if it's valid.
In the original report by kap with "queryselectorall", he is passing the string "table" as a parameter, queryselectorall is expecting css selector to be found in the string, which there aren't any there. The documentation says that if no selector can be found, an exception is raised.
Could it be the exception that you can't seem to catch? As far as I know we should be able to pass incorrect parameter like that and mIRC should handle it, this is assuming objects are never themselves crashing.