Incorrect usage of findAllLive
balupton opened this issue · comments
Inside renderBefore
there is this line:
documents = @docpad.getCollection('documents').findAllLive({relativeDirPath: config.documentPath}, [date: -1])
findAllLive
should only be used when defining long running custom collections, in this case this is a short running custom collection. So what will happen is that each time renderBefore
is emitted, findAllLive
executes, and creates another child collection listening to the parent, causing a memory leak as well as unexpected results.
The solution to this is to move out this line into a new extendCollections
event, as can be seen here in the partials plugin:
https://github.com/docpad/docpad-plugin-partials/blob/master/src/partials.plugin.coffee#L81-L106
Alternatively, you can keep it where it is but just change findAllLive
to findAll
, but it will be less ineffective.
I'll be working on some querying API documentation more obvious and cleaner.
Reported by @ervwalter here https://botbot.me/freenode/docpad/msg/6753357/