mirror of
https://github.com/stablyai/orca.git
synced 2026-10-03 08:02:12 +00:00
test(native-chat): cancel the journal import test's tick before teardown (#24071)
The test re-arms a setImmediate tick while the copy runs and stopped it with a flag. A tick already queued when the import resolved still ran, and when the afterEach teardown closed the database first it threw journal_closed as an unhandled error, failing a CI shard with every test green. Clear the queued tick instead.
This commit is contained in:
@@ -331,23 +331,21 @@ describe('importing a per-chat journal', () => {
|
||||
})
|
||||
)
|
||||
const between: number[] = []
|
||||
let copying = true
|
||||
const tick = (): void => {
|
||||
// What a live chat's append would commit under, between two copy batches.
|
||||
between.push(synchronous())
|
||||
if (copying) {
|
||||
setImmediate(tick)
|
||||
}
|
||||
pending = setImmediate(tick)
|
||||
}
|
||||
|
||||
setImmediate(tick)
|
||||
let pending = setImmediate(tick)
|
||||
await importPerSessionJournal({
|
||||
database,
|
||||
identity: IDENTITY,
|
||||
legacyDirectory: legacyDir(),
|
||||
batchRows: 1
|
||||
})
|
||||
copying = false
|
||||
// A flag would still let the queued tick read the database after teardown closes it.
|
||||
clearImmediate(pending)
|
||||
|
||||
// 2 is FULL, 1 is NORMAL.
|
||||
expect(commits.slice(0, rows.length)).toEqual(rows.map(() => 1))
|
||||
|
||||
Reference in New Issue
Block a user