Repository navigation
Description
Summary
After a course's version goes from 1.0.0 to 1.0.2 (same major), Chrome alternates on every reload: one load shows 1.0.2, the next restores the stored 1.0.0 copy (including its old imported templates/macros), the next shows 1.0.2 again, and so on. It doesn't settle, also with all other tabs closed. The course list on the start page consistently shows 1.0.2; the info pane in the course alternates, and so does the behaviour of the imported template.
Steps to reproduce
- Open a course with
version: 1.0.0on some slide, e.g.…/README.md#6. - Change the course and set
version: 1.0.1(or1.0.2). - Reload the course tab several times and watch the version in the info pane (or anything that differs between the two versions, e.g. an updated imported template).
Expected: from the first reload on, 1.0.1 every time.
Actual: 1.0.1, 1.0.0, 1.0.1, 1.0.0, … (Chrome on macOS; our live course is at 1.0.2 now, so it only shows for browsers that had stored 1.0.0).
Evidence
Console snippet, run after each reload:
(async () => {
const url = decodeURIComponent(location.search.slice(1))
const open = (n) => new Promise((ok, ko) => { const r = indexedDB.open(n); r.onsuccess = () => ok(r.result); r.onerror = ko })
const get = (db, s, k) => new Promise((ok) => { const r = db.transaction(s).objectStore(s).get(k); r.onsuccess = () => ok(r.result) })
const idx = await open('Index'), db = await open(url)
const c = await get(idx, 'courses', url), off = await get(db, 'offline', [0, 1])
console.log('index says:', Object.entries(c.data).map(([k, v]) => k + ' → ' + v.version).join(', '),
'| stored copy is:', off?.data?.definition?.version)
idx.close(); db.close()
})()Output, alternating:
index says: 0 → 0.1.0, 1 → 1.0.0 | stored copy is: 1.0.0 ← load that restored the old copy
index says: 0 → 0.1.0, 1 → 1.0.2 | stored copy is: 1.0.0 ← load that parsed 1.0.2 fresh
After the fresh 1.0.2 load, the index entry says 1.0.2, but the offline copy is still 1.0.0.
Cause (as far as I can trace it, development @ 64734fa)
- The index entry and the
offlinecopy are keyed by the major version only (Lia/Json/Encode.elmL63,Service/Database.elmL167toJson→getMajor), so1.0.0and1.0.2share one slot. - On a load that parses fresh,
index_store(liascript/service/Database.tsL132) callsconnector.open()(L143) without awaiting it, thenconnector.storeToIndex()(L189) →storeIndex(connectors/Browser/database.tsL354) writes the new copy intooffline(put({ id: 0, version: 1, data })). - At the same time
slide()(connectors/Browser/database.tsL246) stores the current slide by reading the wholeofflineitem, settingitem.data.section_activeandputting it back. If itsgetruns beforestoreIndex'sput, itsputwrites the old1.0.0copy back over the new one. - Next load:
load_readme(Update.elmL734) /inCache(Index/Update.elmL675) sees1.0.2in the index, so it restores theofflinecopy, which is1.0.0.load_first_slidethen stores that model again, so the index goes back to1.0.0. The load after that parses fresh again, and the race repeats. - The first version in a slot is safe:
slide()finds no item, throws, and writes nothing.
Suggested fix
Let slide() change only section_active instead of writing back the whole copy, e.g.
await this.db.offline
.where({ id: 0, version: this.version })
.modify((item) => { item.data.section_active = id })Dexie runs modify in a read-write transaction on the current item, so it can no longer resurrect an older copy. (Alternatively, await the open and the storeIndex write before the first slide() call.)
Impact
Updates within a major version, including updated imported templates, only reach every other load for everyone who had opened the previous version. Learners' answers are not affected (separate tables). Our workaround is to delete the course from the start page, which removes its database.
Thanks for LiaScript!
Activity
andre-dietrich commentedon Nov 2, 2026
Thanks for the bug report ... This shall be fixed according to your suggestions. Same as before ... I will update all other tools later ;-) ...
fix(database): store the slide without overwriting a newer offline co…