Bug 2 of 3 · inspired by my TrackTheTrek project

“The trail journal forgot the hike.”

You log two hikes, close the journal, and open it again… and the pages are blank.

The trail journal right after it was reopened, a thought cloud for temporary memory, and a storage chest for saved data. Before the fix, nothing reaches the chest and the journal is blank. After the fix, two hikes are saved and loaded back. in memory: 0 hikesloaded: 2 hikes Trail journal (blank page) Mossy Switchback Loop 4.2 km Cedar Ridge Trail 7.8 km not savingsaving empty2 hikes SAVED STORAGE JUST REOPENED 0 hikes2 hikes ✓
After reopening: the hikes are gone.After reopening: both hikes are back.

journal.pseudothe buggy code

hikes = empty list      // temporary memorywhen you add a hike:    put it in hikeswhen the journal opens:    hikes = empty list    show hikes
hikes = empty list      // temporary memorywhen you add a hike:    put it in hikes    save hikes to storagewhen the journal opens:    hikes = load hikes from storage    show hikes
Which change fixes it?

About this demo

What was the bug?

The hikes only lived in temporary memory, which is wiped when the journal closes. The fix saves them somewhere that lasts and loads them back on open. The real TrackTheTrek app does this with a JSON file.

Honest label: a simplified demonstration inspired by TrackTheTrek. It isn’t a real bug from that project.

Read about TrackTheTrek · Its source on GitHub (opens in a new tab)