XMLHttpRequest and garbage collection

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Henri Sivonen

    XMLHttpRequest and garbage collection

    I got the following error:

    Error: [Exception... "Component returned failure code: 0x80040111
    (NS_ERROR_NOT_A VAILABLE) [nsIXMLHttpReque st.status]" nsresult:
    "0x80040111 (NS_ERROR_NOT_A VAILABLE)"

    .... with Firefox when using XMLHttpRequest. What's happenening? Is the
    object being garbage collected before the network operation finishes?

    My usage pattern is:

    function modelChanged() {
    var req = new XMLHttpRequest( )
    req.open('PUT', ... , true)
    req.onreadystat echange = function() {
    if(req.readySta te == 4) {
    // do stuff
    }
    }
    req.send(docume ntToSend)
    }


    I am not holding a reference to the req object from the global scope.
    Should I? I don't know how many HTTP operations I have going at a given
    moment. What kind of stretchable data structure should I use for holding
    the references to the request objects? Or should I attempt to cancel the
    unfinished connection if another one needs to start before the preceding
    one has finished?

    --
    Henri Sivonen
    hsivonen@iki.fi

  • Martin Honnen

    #2
    Re: XMLHttpRequest and garbage collection



    Henri Sivonen wrote:
    [color=blue]
    > I got the following error:
    >
    > Error: [Exception... "Component returned failure code: 0x80040111
    > (NS_ERROR_NOT_A VAILABLE) [nsIXMLHttpReque st.status]" nsresult:
    > "0x80040111 (NS_ERROR_NOT_A VAILABLE)"
    >
    > ... with Firefox when using XMLHttpRequest. What's happenening? Is the
    > object being garbage collected before the network operation finishes?[/color]

    Are you trying to read the status property at all? Your code below
    doesn't show any access to status.
    [color=blue]
    > function modelChanged() {
    > var req = new XMLHttpRequest( )
    > req.open('PUT', ... , true)
    > req.onreadystat echange = function() {
    > if(req.readySta te == 4) {
    > // do stuff
    > }
    > }
    > req.send(docume ntToSend)
    > }
    >
    >
    > I am not holding a reference to the req object from the global scope.
    > Should I? I don't know how many HTTP operations I have going at a given
    > moment. What kind of stretchable data structure should I use for holding
    > the references to the request objects? Or should I attempt to cancel the
    > unfinished connection if another one needs to start before the preceding
    > one has finished?[/color]

    There is a method called abort to do that
    <http://www.xulplanet.c om/references/objref/XMLHttpRequest. html>
    so perhaps calling that improves things.

    As for the error you get, are you able to use some HTTP sniffer to check
    the HTTP request headers and the HTTP response headers that are occuring
    when Firefox displays the error?
    You could for instance install the extension
    <http://livehttpheaders .mozdev.org/>
    Then it might be easier to say/see why Firefox gives that error and
    whether there is a bug in Mozilla or something else goes wrong.

    But a search on Google groups
    <http://groups-beta.google.com/group/netscape.public .mozilla.dom/browse_frm/thread/2b0670d4fc5a011 0/54be6a36b56d276 f?q=nsIXMLHttpR equest.status+N S_ERROR_NOT_AVA ILABLE&_done=%2 Fgroups%3Fas_q% 3DnsIXMLHttpReq uest.status+NS_ ERROR_NOT_AVAIL ABLE%26safe%3Di mages%26lr%3D%2 6hl%3Den%26&_do neTitle=Back+to +Search&&d#54be 6a36b56d276f>
    shows that others have run into the problem before and it seems there
    are bugs open on bugzilla.

    --

    Martin Honnen

    Comment

    Working...