JS client immediately start->stop->start connection, the first deferred.done is also triggered #2519

Closed
halter73 opened this Issue Sep 5, 2013 · 2 comments

Comments

Projects
None yet
4 participants
Member

halter73 commented Sep 5, 2013

Functional impact:
In JS client when immediately start->stop->start on connection, after connection become connected, the first deferred.done is also triggered.

Note, this is not regression.

Repro:
1). use the asp.net sample HubConnectionAPI
2). in HubConnectionAPI.js, update start function as below:

    start = function () {
        $.connection.hub.start({ transport: activeTransport, jsonp: isJsonp })
            .done(function () {
                $("<li/>").html("started transport: " + $.connection.hub.transport.name + " " + $.connection.hub.id)
                            .appendTo(messages);

                stopStartBtn.prop("disabled", false)
                            .find("span")
                                .text("Stop Connection")
                                .end()
                            .find("i")
                                .removeClass("icon-play")
                                .addClass("icon-stop");

            });

        $.connection.hub.stop();

        $.connection.hub.start({ transport: activeTransport, jsonp: isJsonp })
            .done(function () {
                $("<li/>").html("second started transport: " + $.connection.hub.transport.name + " " + $.connection.hub.id)
                            .appendTo(messages);

                stopStartBtn.prop("disabled", false)
                            .find("span")
                                .text("Stop Connection")
                                .end()
                            .find("i")
                                .removeClass("icon-play")
                                .addClass("icon-stop");

            });
    };

3). request HubConnectionAPI/Default.aspx on IE10 for webSockets transport

Expected result:
the first deferred.done is not triggered

Actual result:
the first deferred.done is also triggered, results like below:

•[11:19:05 PDT]: disconnected => connecting undefined
•[11:19:05 PDT]: connecting => disconnected undefined
•[11:19:05 PDT]: disconnected => connecting undefined
•[11:19:05 PDT]: connecting => connected 88c9e7e3-2fca-4199-992d-1c88dd4539ec
•[11:19:05 PDT]: 0d65e3e7-67d7-4365-91bd-a4ee6da24204 OnConnected
•[11:19:05 PDT]: 0d65e3e7-67d7-4365-91bd-a4ee6da24204 OnConnected
•started transport: webSockets 88c9e7e3-2fca-4199-992d-1c88dd4539ec
•second started transport: webSockets 88c9e7e3-2fca-4199-992d-1c88dd4539ec

#2189

This is the expected behavior of the Deferred pattern. In fact the done should be fired as soon as you call stop.

halter73 was assigned Oct 1, 2013

Contributor

gustavo-armenta commented Oct 21, 2013

tested repro and only second deferred completes

•[15:17:29 GMT-0700 (Pacific Daylight Time)]: disconnected => connecting undefined
•[15:17:29 GMT-0700 (Pacific Daylight Time)]: connecting => connected b3c84ec1-cd07-49f6-a58c-d21e2e8f17c4
•second started transport: webSockets b3c84ec1-cd07-49f6-a58c-d21e2e8f17c4
•[15:17:29 GMT-0700 (Pacific Daylight Time)]: b3c84ec1-cd07-49f6-a58c-d21e2e8f17c4 OnConnected
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment