Repository navigation
Conversation
When the native renderer cannot allocate a text or editor buffer, the error boundary previously tried to draw the full error screen. That screen allocates more text buffers, so it could fail again and surface an unhandled error while the terminal was left in a broken state. Classify the native text and editor allocation failures, skip the error screen for them, restore the terminal, print the original error to stderr, and exit with a nonzero status. Ordinary render errors keep the existing error screen and exit status. Closes #35053
|
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
|
The following comment was made by an LLM, it may be inaccurate: |
|
The issue link is in the ### Issue for this PR\ section (\Closes #35053), so this looks like a false positive from the workflow, not a missing reference. Cause: \pr-standards.yml\ uses \pull_request_target, so it runs the copy on the default branch (\dev). \dev's copy relies on \closingIssuesReferences, which GitHub only populates for PRs targeting the default branch, and it does not contain the description fallback that \�2's copy has. \CONTRIBUTING.md\ says to base on \�2, so I have left the base as \�2. Other v2 PRs (#51385, #51355, #51352, #51337, #51314, #51313) show the same Could a maintainer clear |
Issue for this PR
Closes #35053
Type of change
What does this PR do?
The TUI crashes with
Failed to create TextBufferwhen the native renderer can no longer allocate a text or editor buffer (#35053). Today the error boundary catches that failure and renders the full error screen. That screen allocates more text buffers, so it can fail during the same render and take the TUI down while the terminal is left broken.This PR treats the native text and editor allocation failures as fatal:
isFatalRendererAllocationErrormatches the five allocation errors thrown by@opentui/core(TextBuffer,TextBufferView,EditorView,EditBuffer,SyntaxStyle). When the boundary catches one, it records the error, skips the error screen (returnsnull), and destroys the renderer once so the terminal is restored. The recorded error is then printed to stderr and the process exits with a nonzero status (process.exitCodeis only raised when it is not already a failure). Ordinary render errors keep the existing error screen and exit status.This does not fix the underlying allocation failure; it makes the failure exit cleanly with the original error instead of crashing again while drawing the error screen.
How did you verify your code works?
bun typecheckinpackages/tuipasses.bun test test/util/error.test.tspasses (new classifier test).bun test test/app-lifecycle.test.tsxpasses the four new lifecycle tests (fatal exit nonzero, existing failure status preserved, competing destroy, ordinary error unchanged) and the existing tests. The only failures are the same six pre-existing unrelated failures present on unmodifiedv2on this machine (Windows):keeps the prompt display stable...,execution failure keeps the empty session composer..., and fourserver plugin failures...cases.Screenshots / recordings
N/A (terminal behavior change, no visual output).
Checklist