Skip to content

Commit

Permalink
fix(watch): avoid memleak by not piling up docs (#130)
Browse files Browse the repository at this point in the history
See https://pouchdb.com/api.html#changes return_docs option.

Never use return_docs: true in live mode, what we want is include_docs
  • Loading branch information
vvo committed Feb 13, 2018
1 parent af8e709 commit 4522ee5
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ async function bootstrap(state) {
.allDocs({
...defaultOptions,
...options,
return_docs: false, // eslint-disable-line camelcase
limit: c.bootstrapConcurrency,
})
.then(async res => {
Expand Down Expand Up @@ -174,7 +173,7 @@ async function replicate({ seq }) {
since: seq,
batch_size: c.replicateConcurrency, // eslint-disable-line camelcase
live: true,
return_docs: true, // eslint-disable-line camelcase
return_docs: false, // eslint-disable-line camelcase
});

const q = cargo((docs, done) => {
Expand Down Expand Up @@ -207,7 +206,7 @@ async function replicate({ seq }) {
}
});
});
changes.on('complete', resolve);
changes.on('complete', resolve); // Called when cancel() called
changes.on('error', reject);
});
}
Expand All @@ -222,8 +221,8 @@ function watch({ seq }) {
...defaultOptions,
since: seq,
live: true,
limit: undefined,
return_docs: true, // eslint-disable-line camelcase
batch_size: 1, // eslint-disable-line camelcase
return_docs: false, // eslint-disable-line camelcase
});

const q = queue((change, done) => {
Expand Down

0 comments on commit 4522ee5

Please sign in to comment.