feat(debug): add close() method to DebugSession for resource lifecycle#820
feat(debug): add close() method to DebugSession for resource lifecycle#820luojiyin1987 wants to merge 2 commits into
Conversation
sonukapoor
left a comment
There was a problem hiding this comment.
Thanks for tackling the lifecycle gap - the no-op on the disabled path is exactly right. A couple of things before this goes in though.
The enabled path: right now createDebugLogger uses fs.appendFileSync on every log call, so there's no open file handle to close. The close: () => {} on the enabled path is also a no-op today. That's technically correct, but the PR description says this is for "proper resource cleanup" - so I want to make sure the stream refactor (switching to fs.createWriteStream) is coming in a companion PR. If it is, this makes sense as a foundation. If appendFileSync is staying, I'd rather add close() in the PR that actually needs it so the API doesn't promise something it doesn't deliver. Could you clarify the plan?
Also worth adding a test for the new close() on both paths - even a quick assertion that calling it doesn't throw would document the expected no-op behavior.
|
Thanks for the review. I added a small contract test covering To clarify the plan: this PR is only introducing the lifecycle contract. The actual resource cleanup will come in a follow-up PR that switches the enabled debug logger from |
sonukapoor
left a comment
There was a problem hiding this comment.
Thanks for adding the test - asserting that close() returns undefined on both paths is exactly the right way to document the no-op behavior. The implementation is technically correct today since appendFileSync has no open handle to close. If a future PR switches to fs.createWriteStream, that's the right time to wire up a real close. Happy to merge this as-is.
What
Add
close(): voidto theDebugSessiontype. Both enabled and disabled sessions return a no-opclose().Why
Establishes the lifecycle API needed before moving the enabled debug logger to a stream-backed implementation. In this PR, close() is intentionally a no-op on both paths; actual cleanup will be implemented in the follow-up stream refactor.
Changes
src/output/debug.ts: AddclosetoDebugSessiontype and both return pathsTesting
close()implementations are no-ops)Closes #819