Open
Description
TypeError: Cannot read properties of undefined (reading 'length') (at "Terminal")
How did this happen?
Context:
I have enabled:
Options > Interface > Misc > Enable terminal history search with arrow keys
Steps:
- I saved the game
- Exited the bitnode with
run b1t_flum3.exe
(to check some info about another BN) - Loaded back the game
- Started to write a prompt command.
- Before hit enter, I pressed up to auto-complete
Result:
Game stops. Shows the BUG screen, inviting me to submit an issue on github.
Probable cause:
When I quit the BN, it must have reset my terminal history.
When I load the game back and try to search, the history it's empty. Returns error:
TypeError: Cannot read properties of undefined (reading 'length') (at "Terminal")
3 levels of possible solutions:
A quick solution:
Probably a simple try-catch on terminal history search will fix this specific issue.
A better solution (to avoid it breaking in other places):
Investigate how the terminal history is implemented:
- Typed as array || null?
- Can it be used before initiated?
- Check all interaction points (create, consume, update, delete)
Architecture reflections:
- Besides the search history, what other elements use the same pattern (and could cause bugs)?
- Look for conceptual flaws.
- Should the terminal history be attached to a game session or a BN run?
- Should the history be persisted at the saving file? What are the impacts on that decision?
- When & how should we clean, load and retrieve it?
- What's the desirable / expected gameplay?
Environment
- Error: TypeError: Cannot read properties of undefined (reading 'length')
- Page: Terminal
- Version: v2.6.2 (633da38)
- Environment: Production
- Platform: Steam
- UserAgent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) bitburner/2.6.2 Chrome/116.0.5845.228 Electron/26.3.0 Safari/537.36
- Features: lang=en-GB cookiesEnabled=true doNotTrack=null indexedDb=true
- Source: n/a
Activity