Skip to content
This repository has been archived by the owner on Feb 15, 2022. It is now read-only.

Fix: use lolex only for setTimeout function to avoid mongodb to stall #2425

Merged
merged 1 commit into from
Oct 9, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions lib/engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -758,7 +758,14 @@ module.exports = function (s, conf) {
}

function withOnPeriod (trade, period_id, cb) {
if (!clock && so.mode !== 'live' && so.mode !== 'paper') clock = lolex.install({ shouldAdvanceTime: false, now: trade.time })
if (!clock && so.mode !== 'live' && so.mode !== 'paper') clock = lolex.install(
{
shouldAdvanceTime: false,
now: trade.time,
toFake: [
'setTimeout'
]
})

updatePeriod(trade)
if (!s.in_preroll) {
Expand All @@ -776,7 +783,7 @@ module.exports = function (s, conf) {
clock.tick(5000)
diff -= 5000
}
clock.tick(diff)
clock.tick(diff < 0 ? 1 : diff)
}

if (s.signal) {
Expand Down