Skip to content

Commit

Permalink
lib/entities-store: unref() timers 🐛; 2.1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
derhuerst committed Sep 15, 2024
1 parent 430ee35 commit 7232101
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
15 changes: 12 additions & 3 deletions lib/entities-store.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,20 @@ const createEntitiesStore = (ttl, now) => {
}

const put = (id, entity) => {
// console.error('put', id, entity) // todo: remove
del(id)

// todo: use sth more memory-efficient than closures?
// todo: set expiry relative to entity's timestamp?
timers.set(id, setTimeout(del, ttl, id))
{
// todo: use sth more memory-efficient than closures?
// todo: set expiry relative to entity's timestamp?
const timer = setTimeout(del, ttl, id)
timers.set(id, timer)
if (timer && timer.unref) {
// allow Node.js to exit by not requiring its event loop to remain active
// note: not available in browsers
timer.unref()
}
}

FeedEntity.verify(entity)
const data = FeedEntity.encode(entity).finish()
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "gtfs-rt-differential-to-full-dataset",
"description": "Transform a differential GTFS Realtime feed into a full dataset/dump.",
"version": "2.1.1",
"version": "2.1.2",
"main": "index.js",
"files": [
"index.js",
Expand Down

0 comments on commit 7232101

Please sign in to comment.