refactor(logger): Restore cursor on ui5 serve termination#1475
Open
RandomByte wants to merge 2 commits into
Open
refactor(logger): Restore cursor on ui5 serve termination#1475RandomByte wants to merge 2 commits into
RandomByte wants to merge 2 commits into
Conversation
log-update hides the terminal cursor on every render and only shows it again in its own done(), which InteractiveConsole calls from disable(). On CTRL+C the process is signal-terminated without disable() ever running, so the cursor stays hidden in the user's shell. The restore-cursor safety net (a bare "\x1b[?25h" with no newline) is also swallowed: the stderr write interceptor buffers non-newline-terminated writes into `partial` and only flushes them in disable(). Register a handler for SIGINT/SIGTERM/SIGHUP/SIGBREAK (and an `exit` catch-all) in enable(), removed in disable(). Each signal handler tears the live region down via disable(), then re-raises the signal with process.kill(process.pid, signal) rather than calling process.exit(). Re-raising lets the cooperating handlers in profile.js and ProjectBuilder still run their async cleanup, and lets the default disposition set the 128+n exit code. disable() removes the handlers before re-raise so the re-sent signal reaches the default disposition instead of looping. disable() now also writes the show-cursor escape explicitly to its own stream, after uninstalling the interceptor. log-update's done() targets the real process.stderr and is gated on isTTY, so it can be a no-op; the explicit write restores the cursor regardless and is observable in tests.
RandomByte
marked this pull request as ready for review
July 23, 2026 15:02
d3xter666
requested changes
Jul 24, 2026
Comment on lines
+179
to
+190
| #registerSignalHandlers() { | ||
| for (const signal of TERMINATION_SIGNALS) { | ||
| const handler = () => this.#handleTerminationSignal(signal); | ||
| this.#signalHandlers.set(signal, handler); | ||
| process.on(signal, handler); | ||
| } | ||
| // `exit` covers cooperating handlers that call process.exit(); it never | ||
| // fires on a bare signal kill, hence the signal handlers above. | ||
| const onExit = () => this.disable(); | ||
| this.#signalHandlers.set("exit", onExit); | ||
| process.on("exit", onExit); | ||
| } |
Member
There was a problem hiding this comment.
This method is not idempotent. Calling it twice, will just override this.#signalHandlers, and the firstly registered handlers will not be able to be deleted.
A check for registered signal in this.#signalHandlers will solve the issue
A second enable() without an intervening disable() overwrote every #signalHandlers map entry with fresh closures, stranding the first set of handlers on process. #deregisterSignalHandlers() iterates the map, so it could only detach the latest set, leaking the originals. Guard #registerSignalHandlers() on the map already being populated and return early, mirroring how disable() guards on #stopped. Registration and deregistration happen as a unit, so a single check covers all signals.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The log-update package hides the terminal cursor on every render and only shows it again in its own
done(), which InteractiveConsole calls fromdisable(). On CTRL+C the process is signal-terminated withoutdisable()ever running, so the cursor stays hidden in the user's shell. The restore-cursor safety net (a bare\x1b[?25hwith no newline) is also swallowed: the stderr write interceptor buffers non-newline-terminated writes intopartialand only flushes them indisable().Register a handler for SIGINT/SIGTERM/SIGHUP/SIGBREAK (and an
exitcatch-all) in enable(), removed in disable(). Each signal handler tears the live region down via disable(), then re-raises the signal with process.kill(process.pid, signal) rather than calling process.exit(). Re-raising lets the cooperating handlers in profile.js and ProjectBuilder still run their async cleanup, and lets the default disposition set the 128+n exit code.disable()removes the handlers before re-raise so the re-sent signal reaches the default disposition instead of looping.disable()now also writes the show-cursor escape explicitly to its own stream, after uninstalling the interceptor. log-update's done() targets the real process.stderr and is gated on isTTY, so it can be a no-op; the explicit write restores the cursor regardless and is observable in tests.