Skip to content

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

Open
@GoulartNogueira

Description

@GoulartNogueira

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:

  • 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

Save

RECOVERY_BITBURNER_1720786736.json.gz

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs more infoAdditional info or a reliable bug reproduction method are needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions