Skip to content

Commit

Permalink
fix(memory): don't keep a reference of the chain in watch
Browse files Browse the repository at this point in the history
Reading up on promises and memory leaks, this might be the cause of our leak in the watch phase.

I'm not convinced that this is completely the same or that it will help, but we will see fast.
  • Loading branch information
Haroenv committed May 14, 2017
1 parent a6ca3b5 commit f973913
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,6 @@ function watch({ seq }) {
'🛰 Watch: 👍 We are in sync (or almost). Will now be 🔭 watching for registry updates'
);

let chain = Promise.resolve();

return new Promise((resolve, reject) => {
const changes = db.changes({
...defaultOptions,
Expand All @@ -171,7 +169,7 @@ function watch({ seq }) {
});

changes.on('change', change => {
chain = chain
Promise.resolve()
.then(() => saveDocs([change]), reject)
.then(() => infoChange(change.seq, 1, '🛰'))
.then(() =>
Expand Down

0 comments on commit f973913

Please sign in to comment.