Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
GoulartNogueira opened this issue Jul 12, 2024 · 1 comment
Labels
needs more info Additional info or a reliable bug reproduction method are needed

Comments

@GoulartNogueira
Copy link

GoulartNogueira commented Jul 12, 2024

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

@catloversg
Copy link
Contributor

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

  • Load your save file.
  • run b1t_flum3.exe.
  • I don't know what you mean by "Loaded back the game". I assume that it means "Press F5 to reload the tab browser".
  • Write some commands ("ls", "run", "nano", etc.).
  • "pressed up to auto-complete".

Can you clarify the exact steps?

@gmcew gmcew added the needs more info Additional info or a reliable bug reproduction method are needed label Jul 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs more info Additional info or a reliable bug reproduction method are needed
Projects
None yet
Development

No branches or pull requests

3 participants