-
Notifications
You must be signed in to change notification settings - Fork 5k
Blob.writer(): don't access .FileSink when Start.fromJSWithTag returns .err #30254
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -219,6 +219,13 @@ if (isWindows) { | |||||||
| }); | ||||||||
| } | ||||||||
|
|
||||||||
| it.skipIf(isWindows)("writer() with invalid path/fd options throws instead of crashing", () => { | ||||||||
| const file = path.join(tmpdirSync(), "test.txt"); | ||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion | 🟠 Major | ⚡ Quick win Use Please switch this new temp-path setup to Proposed refactor- const file = path.join(tmpdirSync(), "test.txt");
+ using dir = tempDir("filesink-invalid-options");
+ const file = path.join(dir, "test.txt");Also update imports: -import { fileDescriptorLeakChecker, isPosix, isWindows, tmpdirSync } from "harness";
+import { fileDescriptorLeakChecker, isPosix, isWindows, tempDir, tmpdirSync } from "harness";As per coding guidelines 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||
| expect(() => Bun.file(file).writer({ path: 123 })).toThrow(expect.objectContaining({ code: "EINVAL" })); | ||||||||
| expect(() => Bun.file(file).writer({ fd: "hello" })).toThrow(expect.objectContaining({ code: "EBADF" })); | ||||||||
| expect(() => Bun.file(file).writer({ fd: 2 ** 53 })).toThrow(expect.objectContaining({ code: "EBADF" })); | ||||||||
| }); | ||||||||
|
|
||||||||
| // When a write to a pollable fd returns `.pending`, FileSink takes a | ||||||||
| // `must_be_kept_alive_until_eof` ref on itself so it survives until the | ||||||||
| // buffered data is drained. If the write later fails (e.g. EPIPE because the | ||||||||
|
|
||||||||
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.
Release previous
input_pathbefore overwriting.FileSink.input_pathIf options include a valid
path,fromJSWithTagallocates it; this assignment overwrites that value without deinit, leaking that allocation.Proposed fix
if (stream_start == .FileSink) { + stream_start.FileSink.input_path.deinit(); stream_start.FileSink.input_path = input_path; }📝 Committable suggestion
🤖 Prompt for AI Agents