Solved: IE encounters ERROR_INTERNET_INCORRECT_HANDLE_STATE when opening a popup window

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:'', 'childwindow', popupParameters);
document.forms[0].target = 'childwindow';

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 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.


This entry was posted in Uncategorized and tagged , , . Bookmark the permalink.

3 Responses to Solved: IE encounters ERROR_INTERNET_INCORRECT_HANDLE_STATE when opening a popup window

  1. Hari Ravilla says:

    I’ve banging my head with the same error. The situation with me is it works fine when I launch my code from my Local server but it gives 12019 (ERROR_INTERNET_INCORRECT_HANDLE_STATE) error when I launch my Java application from Test server. Do you have any idea on what must have gone wrong. The only finding which I did is before launching the external URL page I open a new tab and enter my system credentials and authorize the window and after that if I submit and send the request it doesnt give me this error in test environments. If dont authorize the window with system creds it doesnt.

    • Are you possibly switching between different sub domains as part of your security credential switch? I’ve seen situations where different security levels (e.g. One site trusted it the other not) cause IE to switch processes as not share cookies. This could be similar. Alternatively, perhaps site settings related to the authentication on one part of the site but not another?

      • Hari Ravilla says:

        I dont handle any of the credentials part in my code rather I left it upto the browser. However the call that I’m making is from a JAVA (jsp page) to a .aspx page passing on a XML string in post method. Its an AJAX call that I’m doing in the jsp.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s