-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Fix windows memory leak in error case for opening tty & pipe #23235
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
Conversation
…r tty.ts slightly
WalkthroughRefactors TTY handling: replaces global stdin TTY state with a thread-safe StdinTTY abstraction, updates open/close logic for TTYs and pipes with improved allocation/error handling, and rewrites Node.js TTY ReadStream/WriteStream prototypes using class-based wrappers with consolidated methods and platform-conditional behavior. Changes
Suggested reviewers
Pre-merge checks and finishing touches❌ Failed checks (2 warnings)
✅ Passed checks (1 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (3)
src/io/PipeReader.zig
(1 hunks)src/io/source.zig
(2 hunks)src/js/node/tty.ts
(3 hunks)
🧰 Additional context used
📓 Path-based instructions (6)
src/**/*.zig
📄 CodeRabbit inference engine (.cursor/rules/building-bun.mdc)
Implement debug logs in Zig using
const log = bun.Output.scoped(.${SCOPE}, false);
and invokinglog("...", .{})
Files:
src/io/PipeReader.zig
src/io/source.zig
**/*.zig
📄 CodeRabbit inference engine (.cursor/rules/javascriptcore-class.mdc)
**/*.zig
: Declare the extern C symbol in Zig and export a Zig-friendly alias for use
Wrap the Bun____toJS extern in a Zig method that takes a JSGlobalObject and returns JSC.JSValue
**/*.zig
: Format Zig files with zig-format (bun run zig-format)
In Zig, manage memory carefully with allocators and use defer for cleanup
Files:
src/io/PipeReader.zig
src/io/source.zig
src/js/node/**/*.{js,ts}
📄 CodeRabbit inference engine (src/js/CLAUDE.md)
Place Node.js compatibility modules (e.g.,
node:fs
,node:path
) undernode/
Files:
src/js/node/tty.ts
src/js/{builtins,node,bun,thirdparty,internal}/**/*.{js,ts}
📄 CodeRabbit inference engine (src/js/CLAUDE.md)
src/js/{builtins,node,bun,thirdparty,internal}/**/*.{js,ts}
: Use.$call
and.$apply
instead of.call
or.apply
to avoid user tampering
Use string-literalrequire("...")
only (no dynamic or non-literal specifiers)
Author modules as CommonJS-style withrequire(...)
and export viaexport default {}
(no ESMimport
/named exports)
Prefer JSC intrinsics and$
-prefixed private APIs for performance and safety (e.g.,$Array
,$newArrayWithSize
,$putByIdDirectPrivate
,$assert
,$debug
)
Validate function arguments with$isCallable
and throw$ERR_INVALID_ARG_TYPE
for invalid callbacks
Use$isObject
and throw appropriate TypeErrors for constructor/initializer inputs that must be objects
Files:
src/js/node/tty.ts
src/js/**/*.{js,ts}
📄 CodeRabbit inference engine (CLAUDE.md)
src/js/**/*.{js,ts}
: In built-in modules (src/js), require() must use string literals resolved at compile time
In built-in modules (src/js), use export default (converted to a return statement by the preprocessor)
Files:
src/js/node/tty.ts
**/*.{js,ts,tsx}
📄 CodeRabbit inference engine (CLAUDE.md)
Format JavaScript/TypeScript files with Prettier (bun run prettier)
Files:
src/js/node/tty.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Format
What does this PR do?
How did you verify your code works?