Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

removing filter, seems to break polling #213

Closed
frozeman opened this issue May 20, 2015 · 1 comment
Closed

removing filter, seems to break polling #213

frozeman opened this issue May 20, 2015 · 1 comment
Assignees
Labels
Bug Addressing a bug

Comments

@frozeman
Copy link
Contributor

After calling MyFilter.stopWatching() i get:

Uncaught TypeError: Cannot read property 'callback' of undefined    web3.js:3689

pointing to:

RequestManager.prototype.poll = function () {
    this.timeout = setTimeout(this.poll.bind(this), c.ETH_POLLING_TIMEOUT);

    if (!this.polls.length) {
        return;
    }

    if (!this.provider) {
        console.error(errors.InvalidProvider());
        return;
    }

    var payload = Jsonrpc.getInstance().toBatchPayload(this.polls.map(function (data) {
        return data.data;
    }));

    var self = this;
    this.provider.sendAsync(payload, function (error, results) {
        // TODO: console log?
        if (error) {
            return;
        }

        if (!utils.isArray(results)) {
            throw errors.InvalidResponse(results);
        }

        results.map(function (result, index) {
            result.callback = self.polls[index].callback; // <- ERROR is here
            return result;
        }).filter(function (result) {
            var valid = Jsonrpc.getInstance().isValidResponse(result);
            if (!valid) {
                result.callback(errors.InvalidResponse(result));
            }
            return valid;
        }).filter(function (result) {
            return utils.isArray(result.result) && result.result.length > 0;
        }).forEach(function (result) {
            result.callback(null, result.result);
        });
    });
};

It seems like the results returned still have the same index, which does fit with the callback index anymore.
A quick fix would be to check if(self.polls[index]), but we probably should better check if the poll is not firing the non-existing filter anymore, as i got 101 errors of the above type.

@frozeman frozeman added the Bug Addressing a bug label May 20, 2015
@debris
Copy link
Contributor

debris commented May 21, 2015

👍 I will fix it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Addressing a bug
Projects
None yet
Development

No branches or pull requests

2 participants