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

Eventemitter leak in changes() listener in replication (yes, again) #4093

Closed
nolanlawson opened this issue Jul 31, 2015 · 1 comment
Closed
Labels
bug Confirmed bug

Comments

@nolanlawson
Copy link
Member

Apparently we are still able to get memory leaks during replication if the server throws a 503 (local-npm/local-npm#39). I have no idea how that's possible, though, since I thought we fixed and tested that in d8902a1. Maybe it doesn't work if you neglect to cancel() after an error?

@daleharvey
Copy link
Member

So this should hopefully be fixed in 691df0d

adrienverge added a commit to adrienverge/pouchdb that referenced this issue May 16, 2017
Problem
-------

With the idb adapter (default in Chrome), calling `.changes()` or
`.replicate()` with `{live: true}` multiple times results this error,
even when the handler is nicely terminated with `.cancel()`.

    (node) warning: possible EventEmitter memory leak detected. 11
    listeners added. Use emitter.setMaxListeners() to increase limit.

Related to pouchdb#4176, pouchdb#4141, pouchdb#4093, pouchdb#3848, pouchdb#2667, pouchdb#2311, pouchdb#2205, and maybe
others.

How to reproduce the bug?
-------------------------

Run this plunkr:

Alternatively, you can create + cancel a `.changes()` feed a few times:

    changesHandler = db.changes({live: true});
    changesHandler.cancel();
    repeat

About this fix
--------------

The bug comes from the `_change()` API call from the idb adapter [1]
returning `undefined` instead of the `{cancel: function() {...}}` object
it should return [2].
Because of that, the cleanup function in the core module doesn't call
the adapter's `cancel()` function [3], letting a listener into the wild.

This commit fixes that.

[1]: https://github.com/pouchdb/pouchdb/blob/49e4945/packages/node_modules/pouchdb-adapter-idb/src/index.js#L420-L422
[2]: https://github.com/pouchdb/pouchdb/blob/49e4945/packages/node_modules/pouchdb-adapter-idb/src/changes.js#L29-L33
[3]: https://github.com/pouchdb/pouchdb/blob/49e4945/packages/node_modules/pouchdb-core/src/changes.js#L201-L209
adrienverge added a commit to adrienverge/pouchdb that referenced this issue May 16, 2017
Problem
-------

With the idb adapter (default in Chrome), calling `.changes()` or
`.replicate()` with `{live: true}` multiple times results this error,
even when the handler is nicely terminated with `.cancel()`.

    (node) warning: possible EventEmitter memory leak detected. 11
    listeners added. Use emitter.setMaxListeners() to increase limit.

Related to pouchdb#4176, pouchdb#4141, pouchdb#4093, pouchdb#3848, pouchdb#2667, pouchdb#2311, pouchdb#2205, and maybe
others.

How to reproduce the bug?
-------------------------

Run this plunkr: http://plnkr.co/edit/JKCbQ6vwlYClAp6ZSAf4?p=preview

Alternatively, you can create + cancel a `.changes()` feed a few times:

    changesHandler = db.changes({live: true});
    changesHandler.cancel();
    repeat

About this fix
--------------

The bug comes from the `_change()` API call from the idb adapter [1]
returning `undefined` instead of the `{cancel: function() {...}}` object
it should return [2].
Because of that, the cleanup function in the core module doesn't call
the adapter's `cancel()` function [3], letting a listener into the wild.

This commit fixes that.

[1]: https://github.com/pouchdb/pouchdb/blob/49e4945/packages/node_modules/pouchdb-adapter-idb/src/index.js#L420-L422
[2]: https://github.com/pouchdb/pouchdb/blob/49e4945/packages/node_modules/pouchdb-adapter-idb/src/changes.js#L29-L33
[3]: https://github.com/pouchdb/pouchdb/blob/49e4945/packages/node_modules/pouchdb-core/src/changes.js#L201-L209
adrienverge added a commit to adrienverge/pouchdb that referenced this issue May 16, 2017
Problem
-------

With the idb adapter (default in Chrome), calling `.changes()` or
`.replicate()` with `{live: true}` multiple times results this error,
even when the handler is nicely terminated with `.cancel()`.

    (node) warning: possible EventEmitter memory leak detected. 11
    listeners added. Use emitter.setMaxListeners() to increase limit.

Related to pouchdb#4176, pouchdb#4141, pouchdb#4093, pouchdb#3848, pouchdb#2667, pouchdb#2311, pouchdb#2205, and maybe
others.

How to reproduce the bug?
-------------------------

Run this plunkr: http://plnkr.co/edit/JKCbQ6vwlYClAp6ZSAf4?p=preview

Alternatively, you can create + cancel a `.changes()` feed a few times:

    changesHandler = db.changes({live: true});
    changesHandler.cancel();
    repeat

About this fix
--------------

The bug comes from the `_change()` API call from the idb adapter [1]
returning `undefined` instead of the `{cancel: function() {...}}` object
it should return [2]. Because of that, the cleanup function in the core
module doesn't call the adapter's `cancel()` function [3], letting a
listener into the wild.

This commit fixes that.

[1]: https://github.com/pouchdb/pouchdb/blob/49e4945/packages/node_modules/pouchdb-adapter-idb/src/index.js#L420-L422
[2]: https://github.com/pouchdb/pouchdb/blob/49e4945/packages/node_modules/pouchdb-adapter-idb/src/changes.js#L29-L33
[3]: https://github.com/pouchdb/pouchdb/blob/49e4945/packages/node_modules/pouchdb-core/src/changes.js#L201-L209
adrienverge added a commit to adrienverge/pouchdb that referenced this issue May 16, 2017
Problem
-------

With the idb adapter (default in Chrome), calling `.changes()` or
`.replicate()` with `{live: true}` multiple times results in this error,
even when the handler is nicely terminated with `.cancel()`.

    (node) warning: possible EventEmitter memory leak detected. 11
    listeners added. Use emitter.setMaxListeners() to increase limit.

Related to pouchdb#4176, pouchdb#4141, pouchdb#4093, pouchdb#3848, pouchdb#2667, pouchdb#2311, pouchdb#2205, and maybe
others.

How to reproduce the bug?
-------------------------

Run this plunkr: http://plnkr.co/edit/JKCbQ6vwlYClAp6ZSAf4?p=preview

Alternatively, you can create + cancel a `.changes()` feed a few times:

    changesHandler = db.changes({live: true});
    changesHandler.cancel();
    repeat

About this fix
--------------

The bug comes from the `_change()` API call from the idb adapter [1]
returning `undefined` instead of the `{cancel: function() {...}}` object
it should return [2]. Because of that, the cleanup function in the core
module doesn't call the adapter's `cancel()` function [3], letting a
listener into the wild.

This commit fixes that.

[1]: https://github.com/pouchdb/pouchdb/blob/49e4945/packages/node_modules/pouchdb-adapter-idb/src/index.js#L420-L422
[2]: https://github.com/pouchdb/pouchdb/blob/49e4945/packages/node_modules/pouchdb-adapter-idb/src/changes.js#L29-L33
[3]: https://github.com/pouchdb/pouchdb/blob/49e4945/packages/node_modules/pouchdb-core/src/changes.js#L201-L209
adrienverge added a commit to adrienverge/pouchdb that referenced this issue May 16, 2017
Problem
-------

With the idb adapter (default in Chrome), calling `.changes()` or
`.replicate()` with `{live: true}` multiple times results in this error,
even when the handler is nicely terminated with `.cancel()`.

    (node) warning: possible EventEmitter memory leak detected. 11
    listeners added. Use emitter.setMaxListeners() to increase limit.

Related to pouchdb#4176, pouchdb#4141, pouchdb#4093, pouchdb#3848, pouchdb#2667, pouchdb#2311, pouchdb#2205, and maybe
others.

How to reproduce the bug?
-------------------------

Run this plunkr: http://plnkr.co/edit/JKCbQ6vwlYClAp6ZSAf4?p=preview

Alternatively, you can create + cancel a `.changes()` feed a few times:

    changesHandler = db.changes({live: true});
    changesHandler.cancel();
    repeat

About this fix
--------------

The bug comes from the `_change()` API call from the idb adapter [1]
returning `undefined` instead of the `{cancel: function() {...}}` object
it should return [2]. Because of that, the cleanup function in the core
module doesn't call the adapter's `cancel()` function [3], letting a
listener into the wild.

This commit fixes that.

[1]: https://github.com/pouchdb/pouchdb/blob/49e4945/packages/node_modules/pouchdb-adapter-idb/src/index.js#L420-L422
[2]: https://github.com/pouchdb/pouchdb/blob/49e4945/packages/node_modules/pouchdb-adapter-idb/src/changes.js#L29-L33
[3]: https://github.com/pouchdb/pouchdb/blob/49e4945/packages/node_modules/pouchdb-core/src/changes.js#L201-L209
adrienverge added a commit to adrienverge/pouchdb that referenced this issue May 23, 2017
Problem
-------

With the idb adapter (default in Chrome), calling `.changes()` or
`.replicate()` with `{live: true}` multiple times results in this error,
even when the handler is nicely terminated with `.cancel()`.

    (node) warning: possible EventEmitter memory leak detected. 11
    listeners added. Use emitter.setMaxListeners() to increase limit.

Related to pouchdb#4176, pouchdb#4141, pouchdb#4093, pouchdb#3848, pouchdb#2667, pouchdb#2311, pouchdb#2205, and maybe
others.

How to reproduce the bug?
-------------------------

Run this plunkr: http://plnkr.co/edit/JKCbQ6vwlYClAp6ZSAf4?p=preview

Alternatively, you can create + cancel a `.changes()` feed a few times:

    changesHandler = db.changes({live: true});
    changesHandler.cancel();
    repeat

About this fix
--------------

The bug comes from the `_change()` API call from the idb adapter [1]
returning `undefined` instead of the `{cancel: function() {...}}` object
it should return [2]. Because of that, the cleanup function in the core
module doesn't call the adapter's `cancel()` function [3], letting a
listener into the wild.

This commit fixes that and adds a test to check for the presence of the
error log line.

[1]: https://github.com/pouchdb/pouchdb/blob/49e4945/packages/node_modules/pouchdb-adapter-idb/src/index.js#L420-L422
[2]: https://github.com/pouchdb/pouchdb/blob/49e4945/packages/node_modules/pouchdb-adapter-idb/src/changes.js#L29-L33
[3]: https://github.com/pouchdb/pouchdb/blob/49e4945/packages/node_modules/pouchdb-core/src/changes.js#L201-L209
adrienverge added a commit to adrienverge/pouchdb that referenced this issue May 23, 2017
Problem
-------

With the idb adapter (default in Chrome), calling `.changes()` or
`.replicate()` with `{live: true}` multiple times results in this error,
even when the handler is nicely terminated with `.cancel()`.

    (node) warning: possible EventEmitter memory leak detected. 11
    listeners added. Use emitter.setMaxListeners() to increase limit.

Related to pouchdb#4176, pouchdb#4141, pouchdb#4093, pouchdb#3848, pouchdb#2667, pouchdb#2311, pouchdb#2205, and maybe
others.

How to reproduce the bug?
-------------------------

Run this plunkr: http://plnkr.co/edit/JKCbQ6vwlYClAp6ZSAf4?p=preview

Alternatively, you can create + cancel a `.changes()` feed a few times:

    changesHandler = db.changes({live: true});
    changesHandler.cancel();
    repeat

About this fix
--------------

The bug comes from the `_change()` API call from the idb adapter [1]
returning `undefined` instead of the `{cancel: function() {...}}` object
it should return [2]. Because of that, the cleanup function in the core
module doesn't call the adapter's `cancel()` function [3], letting a
listener into the wild.

This commit fixes that and adds a test to check for the presence of the
error log line.

[1]: https://github.com/pouchdb/pouchdb/blob/49e4945/packages/node_modules/pouchdb-adapter-idb/src/index.js#L420-L422
[2]: https://github.com/pouchdb/pouchdb/blob/49e4945/packages/node_modules/pouchdb-adapter-idb/src/changes.js#L29-L33
[3]: https://github.com/pouchdb/pouchdb/blob/49e4945/packages/node_modules/pouchdb-core/src/changes.js#L201-L209
adrienverge added a commit to adrienverge/pouchdb that referenced this issue May 23, 2017
Problem
-------

With the idb adapter (default in Chrome), calling `.changes()` or
`.replicate()` with `{live: true}` multiple times results in this error,
even when the handler is nicely terminated with `.cancel()`.

    (node) warning: possible EventEmitter memory leak detected. 11
    listeners added. Use emitter.setMaxListeners() to increase limit.

Related to pouchdb#4176, pouchdb#4141, pouchdb#4093, pouchdb#3848, pouchdb#2667, pouchdb#2311, pouchdb#2205, and maybe
others.

How to reproduce the bug?
-------------------------

Run this plunkr: http://plnkr.co/edit/JKCbQ6vwlYClAp6ZSAf4?p=preview

Alternatively, you can create + cancel a `.changes()` feed a few times:

    changesHandler = db.changes({live: true});
    changesHandler.cancel();
    repeat

About this fix
--------------

The bug comes from the `_change()` API call from the idb adapter [1]
returning `undefined` instead of the `{cancel: function() {...}}` object
it should return [2]. Because of that, the cleanup function in the core
module doesn't call the adapter's `cancel()` function [3], letting a
listener into the wild.

This commit fixes that and adds a test to check for the presence of the
error log line.

[1]: https://github.com/pouchdb/pouchdb/blob/49e4945/packages/node_modules/pouchdb-adapter-idb/src/index.js#L420-L422
[2]: https://github.com/pouchdb/pouchdb/blob/49e4945/packages/node_modules/pouchdb-adapter-idb/src/changes.js#L29-L33
[3]: https://github.com/pouchdb/pouchdb/blob/49e4945/packages/node_modules/pouchdb-core/src/changes.js#L201-L209
adrienverge added a commit to adrienverge/pouchdb that referenced this issue May 23, 2017
Problem
-------

With the idb adapter (default in Chrome), calling `.changes()` or
`.replicate()` with `{live: true}` multiple times results in this error,
even when the handler is nicely terminated with `.cancel()`.

    (node) warning: possible EventEmitter memory leak detected. 11
    listeners added. Use emitter.setMaxListeners() to increase limit.

Related to pouchdb#4176, pouchdb#4141, pouchdb#4093, pouchdb#3848, pouchdb#2667, pouchdb#2311, pouchdb#2205, and maybe
others.

How to reproduce the bug?
-------------------------

Run this plunkr: http://plnkr.co/edit/JKCbQ6vwlYClAp6ZSAf4?p=preview

Alternatively, you can create + cancel a `.changes()` feed a few times:

    changesHandler = db.changes({live: true});
    changesHandler.cancel();
    repeat

About this fix
--------------

The bug comes from the `_change()` API call from the idb adapter [1]
returning `undefined` instead of the `{cancel: function() {...}}` object
it should return [2]. Because of that, the cleanup function in the core
module doesn't call the adapter's `cancel()` function [3], letting a
listener into the wild.

This commit fixes that and adds a test to check for the presence of the
error log line.

[1]: https://github.com/pouchdb/pouchdb/blob/49e4945/packages/node_modules/pouchdb-adapter-idb/src/index.js#L420-L422
[2]: https://github.com/pouchdb/pouchdb/blob/49e4945/packages/node_modules/pouchdb-adapter-idb/src/changes.js#L29-L33
[3]: https://github.com/pouchdb/pouchdb/blob/49e4945/packages/node_modules/pouchdb-core/src/changes.js#L201-L209
adrienverge added a commit to adrienverge/pouchdb that referenced this issue May 23, 2017
Problem
-------

With the idb adapter (default in Chrome), calling `.changes()` or
`.replicate()` with `{live: true}` multiple times results in this error,
even when the handler is nicely terminated with `.cancel()`.

    (node) warning: possible EventEmitter memory leak detected. 11
    listeners added. Use emitter.setMaxListeners() to increase limit.

Related to pouchdb#4176, pouchdb#4141, pouchdb#4093, pouchdb#3848, pouchdb#2667, pouchdb#2311, pouchdb#2205, and maybe
others.

How to reproduce the bug?
-------------------------

Run this plunkr: http://plnkr.co/edit/JKCbQ6vwlYClAp6ZSAf4?p=preview

Alternatively, you can create + cancel a `.changes()` feed a few times:

    changesHandler = db.changes({live: true});
    changesHandler.cancel();
    repeat

About this fix
--------------

The bug comes from the `_change()` API call from the idb adapter [1]
returning `undefined` instead of the `{cancel: function() {...}}` object
it should return [2]. Because of that, the cleanup function in the core
module doesn't call the adapter's `cancel()` function [3], letting a
listener into the wild.

This commit fixes that and adds a test to check for the presence of the
error log line.

[1]: https://github.com/pouchdb/pouchdb/blob/49e4945/packages/node_modules/pouchdb-adapter-idb/src/index.js#L420-L422
[2]: https://github.com/pouchdb/pouchdb/blob/49e4945/packages/node_modules/pouchdb-adapter-idb/src/changes.js#L29-L33
[3]: https://github.com/pouchdb/pouchdb/blob/49e4945/packages/node_modules/pouchdb-core/src/changes.js#L201-L209
adrienverge added a commit to adrienverge/pouchdb that referenced this issue May 24, 2017
Problem
-------

With the idb adapter (default in Chrome), calling `.changes()` or
`.replicate()` with `{live: true}` multiple times results in this error,
even when the handler is nicely terminated with `.cancel()`.

    (node) warning: possible EventEmitter memory leak detected. 11
    listeners added. Use emitter.setMaxListeners() to increase limit.

Related to pouchdb#4176, pouchdb#4141, pouchdb#4093, pouchdb#3848, pouchdb#2667, pouchdb#2311, pouchdb#2205, and maybe
others.

How to reproduce the bug?
-------------------------

Run this plunkr: http://plnkr.co/edit/JKCbQ6vwlYClAp6ZSAf4?p=preview

Alternatively, you can create + cancel a `.changes()` feed a few times:

    changesHandler = db.changes({live: true});
    changesHandler.cancel();
    repeat

About this fix
--------------

The bug comes from the `_change()` API call from the idb adapter [1]
returning `undefined` instead of the `{cancel: function() {...}}` object
it should return [2]. Because of that, the cleanup function in the core
module doesn't call the adapter's `cancel()` function [3], letting a
listener into the wild.

This commit fixes that and adds a test to check for the presence of the
error log line.

[1]: https://github.com/pouchdb/pouchdb/blob/49e4945/packages/node_modules/pouchdb-adapter-idb/src/index.js#L420-L422
[2]: https://github.com/pouchdb/pouchdb/blob/49e4945/packages/node_modules/pouchdb-adapter-idb/src/changes.js#L29-L33
[3]: https://github.com/pouchdb/pouchdb/blob/49e4945/packages/node_modules/pouchdb-core/src/changes.js#L201-L209
adrienverge added a commit to adrienverge/pouchdb that referenced this issue May 24, 2017
Problem
-------

With the idb adapter (default in Chrome), calling `.changes()` or
`.replicate()` with `{live: true}` multiple times results in this error,
even when the handler is nicely terminated with `.cancel()`.

    (node) warning: possible EventEmitter memory leak detected. 11
    listeners added. Use emitter.setMaxListeners() to increase limit.

Related to pouchdb#4176, pouchdb#4141, pouchdb#4093, pouchdb#3848, pouchdb#2667, pouchdb#2311, pouchdb#2205, and maybe
others.

How to reproduce the bug?
-------------------------

Run this plunkr: http://plnkr.co/edit/JKCbQ6vwlYClAp6ZSAf4?p=preview

Alternatively, you can create + cancel a `.changes()` feed a few times:

    changesHandler = db.changes({live: true});
    changesHandler.cancel();
    repeat

About this fix
--------------

The bug comes from the `_change()` API call from the idb adapter [1]
returning `undefined` instead of the `{cancel: function() {...}}` object
it should return [2]. Because of that, the cleanup function in the core
module doesn't call the adapter's `cancel()` function [3], letting a
listener into the wild.

This commit fixes that and adds a test to check for the presence of the
error log line.

[1]: https://github.com/pouchdb/pouchdb/blob/49e4945/packages/node_modules/pouchdb-adapter-idb/src/index.js#L420-L422
[2]: https://github.com/pouchdb/pouchdb/blob/49e4945/packages/node_modules/pouchdb-adapter-idb/src/changes.js#L29-L33
[3]: https://github.com/pouchdb/pouchdb/blob/49e4945/packages/node_modules/pouchdb-core/src/changes.js#L201-L209
adrienverge added a commit to adrienverge/pouchdb that referenced this issue May 24, 2017
Problem
-------

With the idb adapter (default in Chrome), calling `.changes()` or
`.replicate()` with `{live: true}` multiple times results in this error,
even when the handler is nicely terminated with `.cancel()`.

    (node) warning: possible EventEmitter memory leak detected. 11
    listeners added. Use emitter.setMaxListeners() to increase limit.

Related to pouchdb#4176, pouchdb#4141, pouchdb#4093, pouchdb#3848, pouchdb#2667, pouchdb#2311, pouchdb#2205, and maybe
others.

How to reproduce the bug?
-------------------------

Run this plunkr: http://plnkr.co/edit/JKCbQ6vwlYClAp6ZSAf4?p=preview

Alternatively, you can create + cancel a `.changes()` feed a few times:

    changesHandler = db.changes({live: true});
    changesHandler.cancel();
    repeat

About this fix
--------------

The bug comes from the `_change()` API call from the idb adapter [1]
returning `undefined` instead of the `{cancel: function() {...}}` object
it should return [2]. Because of that, the cleanup function in the core
module doesn't call the adapter's `cancel()` function [3], letting a
listener into the wild.

This commit fixes that and adds a test to check for the presence of the
error log line.

[1]: https://github.com/pouchdb/pouchdb/blob/49e4945/packages/node_modules/pouchdb-adapter-idb/src/index.js#L420-L422
[2]: https://github.com/pouchdb/pouchdb/blob/49e4945/packages/node_modules/pouchdb-adapter-idb/src/changes.js#L29-L33
[3]: https://github.com/pouchdb/pouchdb/blob/49e4945/packages/node_modules/pouchdb-core/src/changes.js#L201-L209
adrienverge added a commit to adrienverge/pouchdb that referenced this issue May 24, 2017
Problem
-------

With the idb adapter (default in Chrome), calling `.changes()` or
`.replicate()` with `{live: true}` multiple times results in this error,
even when the handler is nicely terminated with `.cancel()`.

    (node) warning: possible EventEmitter memory leak detected. 11
    listeners added. Use emitter.setMaxListeners() to increase limit.

Related to pouchdb#4176, pouchdb#4141, pouchdb#4093, pouchdb#3848, pouchdb#2667, pouchdb#2311, pouchdb#2205, and maybe
others.

How to reproduce the bug?
-------------------------

Run this plunkr: http://plnkr.co/edit/JKCbQ6vwlYClAp6ZSAf4?p=preview

Alternatively, you can create + cancel a `.changes()` feed a few times:

    changesHandler = db.changes({live: true});
    changesHandler.cancel();
    repeat

About this fix
--------------

The bug comes from the `_change()` API call from the idb adapter [1]
returning `undefined` instead of the `{cancel: function() {...}}` object
it should return [2]. Because of that, the cleanup function in the core
module doesn't call the adapter's `cancel()` function [3], letting a
listener into the wild.

This commit fixes that and adds a test to check for the presence of the
error log line.

[1]: https://github.com/pouchdb/pouchdb/blob/49e4945/packages/node_modules/pouchdb-adapter-idb/src/index.js#L420-L422
[2]: https://github.com/pouchdb/pouchdb/blob/49e4945/packages/node_modules/pouchdb-adapter-idb/src/changes.js#L29-L33
[3]: https://github.com/pouchdb/pouchdb/blob/49e4945/packages/node_modules/pouchdb-core/src/changes.js#L201-L209
daleharvey pushed a commit that referenced this issue May 28, 2017
Problem
-------

With the idb adapter (default in Chrome), calling `.changes()` or
`.replicate()` with `{live: true}` multiple times results in this error,
even when the handler is nicely terminated with `.cancel()`.

    (node) warning: possible EventEmitter memory leak detected. 11
    listeners added. Use emitter.setMaxListeners() to increase limit.

Related to #4176, #4141, #4093, #3848, #2667, #2311, #2205, and maybe
others.

How to reproduce the bug?
-------------------------

Run this plunkr: http://plnkr.co/edit/JKCbQ6vwlYClAp6ZSAf4?p=preview

Alternatively, you can create + cancel a `.changes()` feed a few times:

    changesHandler = db.changes({live: true});
    changesHandler.cancel();
    repeat

About this fix
--------------

The bug comes from the `_change()` API call from the idb adapter [1]
returning `undefined` instead of the `{cancel: function() {...}}` object
it should return [2]. Because of that, the cleanup function in the core
module doesn't call the adapter's `cancel()` function [3], letting a
listener into the wild.

This commit fixes that and adds a test to check for the presence of the
error log line.

[1]: https://github.com/pouchdb/pouchdb/blob/49e4945/packages/node_modules/pouchdb-adapter-idb/src/index.js#L420-L422
[2]: https://github.com/pouchdb/pouchdb/blob/49e4945/packages/node_modules/pouchdb-adapter-idb/src/changes.js#L29-L33
[3]: https://github.com/pouchdb/pouchdb/blob/49e4945/packages/node_modules/pouchdb-core/src/changes.js#L201-L209
adrienverge added a commit to adrienverge/pouchdb that referenced this issue May 28, 2017
Problem
-------

With the idb adapter (default in Chrome), calling `.changes()` or
`.replicate()` with `{live: true}` multiple times results in this error,
even when the handler is nicely terminated with `.cancel()`.

    (node) warning: possible EventEmitter memory leak detected. 11
    listeners added. Use emitter.setMaxListeners() to increase limit.

Related to pouchdb#4176, pouchdb#4141, pouchdb#4093, pouchdb#3848, pouchdb#2667, pouchdb#2311, pouchdb#2205, and maybe
others.

How to reproduce the bug?
-------------------------

Run this plunkr: http://plnkr.co/edit/JKCbQ6vwlYClAp6ZSAf4?p=preview

Alternatively, you can create + cancel a `.changes()` feed a few times:

    changesHandler = db.changes({live: true});
    changesHandler.cancel();
    repeat

About this fix
--------------

The bug comes from the `_change()` API call from the idb adapter [1]
returning `undefined` instead of the `{cancel: function() {...}}` object
it should return [2]. Because of that, the cleanup function in the core
module doesn't call the adapter's `cancel()` function [3], letting a
listener into the wild.

This commit fixes that and adds a test to check for the presence of the
error log line.

[1]: https://github.com/pouchdb/pouchdb/blob/49e4945/packages/node_modules/pouchdb-adapter-idb/src/index.js#L420-L422
[2]: https://github.com/pouchdb/pouchdb/blob/49e4945/packages/node_modules/pouchdb-adapter-idb/src/changes.js#L29-L33
[3]: https://github.com/pouchdb/pouchdb/blob/49e4945/packages/node_modules/pouchdb-core/src/changes.js#L201-L209
daleharvey pushed a commit that referenced this issue Jun 4, 2017
Problem
-------

With the idb adapter (default in Chrome), calling `.changes()` or
`.replicate()` with `{live: true}` multiple times results in this error,
even when the handler is nicely terminated with `.cancel()`.

    (node) warning: possible EventEmitter memory leak detected. 11
    listeners added. Use emitter.setMaxListeners() to increase limit.

Related to #4176, #4141, #4093, #3848, #2667, #2311, #2205, and maybe
others.

How to reproduce the bug?
-------------------------

Run this plunkr: http://plnkr.co/edit/JKCbQ6vwlYClAp6ZSAf4?p=preview

Alternatively, you can create + cancel a `.changes()` feed a few times:

    changesHandler = db.changes({live: true});
    changesHandler.cancel();
    repeat

About this fix
--------------

The bug comes from the `_change()` API call from the idb adapter [1]
returning `undefined` instead of the `{cancel: function() {...}}` object
it should return [2]. Because of that, the cleanup function in the core
module doesn't call the adapter's `cancel()` function [3], letting a
listener into the wild.

This commit fixes that and adds a test to check for the presence of the
error log line.

[1]: https://github.com/pouchdb/pouchdb/blob/49e4945/packages/node_modules/pouchdb-adapter-idb/src/index.js#L420-L422
[2]: https://github.com/pouchdb/pouchdb/blob/49e4945/packages/node_modules/pouchdb-adapter-idb/src/changes.js#L29-L33
[3]: https://github.com/pouchdb/pouchdb/blob/49e4945/packages/node_modules/pouchdb-core/src/changes.js#L201-L209
daleharvey pushed a commit that referenced this issue Jun 4, 2017
Problem
-------

With the idb adapter (default in Chrome), calling `.changes()` or
`.replicate()` with `{live: true}` multiple times results in this error,
even when the handler is nicely terminated with `.cancel()`.

    (node) warning: possible EventEmitter memory leak detected. 11
    listeners added. Use emitter.setMaxListeners() to increase limit.

Related to #4176, #4141, #4093, #3848, #2667, #2311, #2205, and maybe
others.

How to reproduce the bug?
-------------------------

Run this plunkr: http://plnkr.co/edit/JKCbQ6vwlYClAp6ZSAf4?p=preview

Alternatively, you can create + cancel a `.changes()` feed a few times:

    changesHandler = db.changes({live: true});
    changesHandler.cancel();
    repeat

About this fix
--------------

The bug comes from the `_change()` API call from the idb adapter [1]
returning `undefined` instead of the `{cancel: function() {...}}` object
it should return [2]. Because of that, the cleanup function in the core
module doesn't call the adapter's `cancel()` function [3], letting a
listener into the wild.

This commit fixes that and adds a test to check for the presence of the
error log line.

[1]: https://github.com/pouchdb/pouchdb/blob/49e4945/packages/node_modules/pouchdb-adapter-idb/src/index.js#L420-L422
[2]: https://github.com/pouchdb/pouchdb/blob/49e4945/packages/node_modules/pouchdb-adapter-idb/src/changes.js#L29-L33
[3]: https://github.com/pouchdb/pouchdb/blob/49e4945/packages/node_modules/pouchdb-core/src/changes.js#L201-L209
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Confirmed bug
Projects
None yet
Development

No branches or pull requests

2 participants