One of our engineers asked me to take a look at a bizarre problem in an application. When accessing the application using IE8, they would click a link that opens a popup window. Rather than the popup window loading, the user would encounter a generic “Internet Explorer cannot display the webpage”, with the unhelpful “Diagnose Connection Problems” button.
The site was definitely up, but this popup window was behaving as if it wasn’t available.
We captured an HttpWatch of the interaction to see exactly what was happening under the covers, and the results were even stranger. The browser was encountering an “ERROR_INTERNET_INCORRECT_HANDLE_STATE” condition. I hadn’t heard of this one, and running some Google searches showed that this was some low-level issues in connection management. How could our site cause that?
After troubleshooting for a while, I decided as an experiment to disable the IE8 process model and put it back in IE7 process mode. With IE8, Microsoft added some sophisticated multi-process logic where different tabs or windows were handled by separate IE processes, and their session state was supposed to be merged. I’ve seen some funky bugs in this area before, so I have often found it helpful to see if disabling it has an effect.
I added the TabProcGrowth registry key and tried again. This time, sure enough, the page loaded into the popup window just fine. This wasn’t a solution, but it was a clue that something was going wrong with IE’s attempts to juggle two underlying processes.
The underlying mechanism that IE uses when deciding whether to spawn off separate windows is hard to understand, but I decided to look more closely at how this window was being opened to see if there was anything unusual that might explain the bug.
Sure enough, there was something strange. Rather than opening a popup window with a link to the subsequent page, the window was being opened with no url at all, and then a form was being submitted with the popup as a target:
window.open('', 'childwindow', popupParameters); document.forms[0].target = 'childwindow'; document.forms[0].submit();
Definitely unusual! I theorized that when this no-url popup window was being opened, IE was creating a separate process for it. Then, when a new page was posted into it, something went wrong with session merging logic when it tried to reconnect back to the main site’s process, and the whole thing ran off the rails, leading to the ERROR_INTERNET_INCORRECT_HANDLE_STATE error.
We changed the window.open call to provide a valid stub page (i.e. blank.htm) that was hosted on the site itself and tried again. Sure enough, the window loaded up fine.
My assumption is that because the window was now loading with a normal link, it either did not need to spawn off another process, or else it was able to avoid some bug in the session merging process.
Anyways, a very bizarre problem. I’m posting here, since the existing results of a search for ERROR_INTERNET_INCORRECT_HANDLE_STATE don’t turn much of anything useful in this regard.
