bitburner-official / bitburner-src

Bitburner source code.
Other
779 stars 256 forks source link

[BUG] Game broke on terminal history search - TypeError: Cannot read properties of undefined (reading 'length') (at "Terminal") #1482

Open GoulartNogueira opened 2 months ago

GoulartNogueira commented 2 months ago

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:
  1. I saved the game
  2. Exited the bitnode with run b1t_flum3.exe (to check some info about another BN)
  3. Loaded back the game
  4. Started to write a prompt command.
  5. 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:

Architecture reflections:

Environment

Save

RECOVERY_BITBURNER_1720786736.json.gz

catloversg commented 2 months ago

I cannot reproduce it with your save file. This is how I did it:

Can you clarify the exact steps?