-
Notifications
You must be signed in to change notification settings - Fork 24
Exception at vertxEventBusService.removeListener() after reconnect #52
Comments
@leolux You are using the the plugin already for some time, I'm remembering. You have no problems with the 1.0.0? I'll look into it later this day. |
Ok. I have added in 4f2d763 an additional timer service for my "IT". I cannot see any problem here. What's the difference? |
|
I have tested version 1.0.0. just now. The error picture is almost identical: |
@leolux Well, must be. Because between 1.0.0 and 1.1.0 was not changed anything in that area. Can you show me the difference to the sample I've given (it) and yours? |
Ok. I must setup your example first. I honestly don't know how to run this code/test. I haven't used e2e before. |
Do I just have to run the list of commands and steps you have described? I have npm and all that stuff installed already. |
See here : #52 (comment) |
On canary branch "npm run-script install-it-vertx-server" gives me this error: Der Befehl "." ist entweder falsch geschrieben oder npm ERR! Windows_NT 6.3.9600 |
I used my git bash to run this command |
If you have the Git Bash installed, you can try to run the commands from this (its more unix/posix compatible). Alternatively you have to reply the commands of the script. |
test\e2e\vertx\install.sh: line 2: wget: command not found. I have to install wget first. I'll finish my test tomorrow. |
wget seems to have some problems, even when running as administrator: |
Anyway. The difference to your example is that I remove the previous listener explicitly in step 7 during handling of the event "connected". |
Ah, okay. That it is. During reconnect. Thanks. |
@leolux |
1.1.1.is still producing the same error 2 lines later: |
In line 549 "callbackMap.get(callback)" evaluates to undefined: The parameter "callback" references the following function: function () {
var index;
if (unregisterFn) {
unregisterFn();
}
if (wrapped.handlers[address]) {
index = wrapped.handlers[address].indexOf(callback);
if (index > -1) {
wrapped.handlers[address].splice(index, 1);
}
}
if (wrapped.handlers[address].length < 1) {
wrapped.handlers[address] = void 0;
}
} So "unregisterHandler" should not be invoked, when callbackMap.get(callback)) returns undefined. |
@leolux It would be helpful if you can specify the situation more precisely. Which calls are you invoking exactly? I need a difference between your setup and the provided IT ( angular-vertxbus/test/e2e/web/app.js Lines 33 to 43 in 0bbc9c8
|
I've created a simple reproducer: https://github.com/leolux/angular-vertxbus_removelistener |
Thank you. Ehm.. perhaps it was not clear enough (it is same pattern as in AJS): var unregisterfn = null;
function registerBusListener(vertxEventBusService) {
unregisterfn = vertxEventBusService.on('inbound.test', function(message) {
console.log('<<<<<<<<<< ', message);
});
console.log('Listener registered');
}
function unregisterBusListener(vertxEventBusService) {
if (typeof unregisterfn === 'function') {
vertxEventBusService.removeListener('inbound.test', unregisterfn);
console.log('Listener unregistered');
}
} The last piece is wrong. The function unregisterBusListener(vertxEventBusService) {
if (typeof unregisterfn === 'function') {
unregisterfn();
console.log('Listener unregistered');
}
} |
Ok, Thank you! |
var callback = function () {};
vertxEventBusService.register('address', callback);
vertxEventBusService.unregister('address', callback); |
There are still 2 issues with the unregisterHandler() function after a successfull reconnect. I updated the reproducer and added buttons to register and unregister. The two issues are marked in step 7 and 9. |
what do you mean with "The two issues are marked in step 7 and 9" ? |
Ah, got it. |
Okay, the unregister function is invalid after using. I can add a guard for this prohibiting abuse. |
Furthermore I don't understand the concept behind the registerHandler() function. Currently it is possible to register more than one handler for the same address which doesn't make much sens to me. For example a client that reconnects to the server after a server restart receives every message from the server twice because the reconnect itself automatically reconnects the intial handler and the client also registers a handler during the "connected" event. Maybe we could distinguish between an "connected" event for initialization of the handlers and a new type of event like "reconnected" which tells the client to process further but without adding handlers again. |
This would solve issue 2 (step 9), but would it also solve the first issue in step 7? |
Will have to run your project actually to confirm this issue. Later. Atm I cannot confirm this, because my own tests do not have this issue (reconnect works, but deconstruction also) |
Alright, thx. |
Why should a client not be able to listen to the same address twice? The client should not know a global state of active listeners.. ?!
Well, you said it already. Do not register on reconnect. Register once and be happy. |
I agree that a client can handle both connects and reconnects the correct way itself. But the thing is that a user of this adapter must take care of the difference between the initial connect event and the connect event after a reconnect itself because there is no separate event for this. If the user does not distinguish these scenarios, than the client accidentally receives messages twice. I think it would be more clear for users to have that distinction built into the API. Maybe this could be an enhancement for a later release. |
The point is: you can register for an address without being connected. That is the thing using |
I actually don't know if the client receives two messages from the server or only one message which gets distributed to the client listeners internally. If the server would send the message twice than it would waste resources. |
That sounds nice. Didn't know about that yet. |
Just to make it clear. Are both of the following ways supposed to do the same job of removing a listener?
|
Both: yes
|
I have tested both ways. Currently the first way (using unregisterfn()) contains one or two issues after a reconnect: |
Please try 1.1.2 |
I have updated https://github.com/leolux/angular-vertxbus_removelistener to use version 1.1.2. It seems to have fixed the second issue because the error does not occur anymore. Unfortunately the client still receives messages from the server, although the button "Unregister" has been pushed after the reconnect. |
Ok, found a bug: #55 New bugs please in a new issue. Thank you! |
In the current release 1.1.0 I get the following exception after the vertx server has rebooted:
Error: Parameter handler must be specified
at checkSpecified (index.js:193)
at vertx.EventBus.that.unregisterHandler (index.js:83)
at Object.angular.module.provider.$get.EventBusStub.unregisterHandler (angular-vertxbus.js:223)
at Object.angular.module.provider.$get.util.unregisterHandler (angular-vertxbus.js:547)
at Object.angular.module.provider.$get.wrapped.unregisterHandler (angular-vertxbus.js:664)
Steps to reproduce:
The exception occures every time these steps are finished, although the last parameter unregisterfunction is not undefined.
The text was updated successfully, but these errors were encountered: