Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/jsc/ConsoleObject.rs
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,15 @@ fn message_with_type_and_level_(
}
}

if message_type == MessageType::Assert && print_length > 0 {
let text: &str = if enable_colors {
pfmt!("<r><red>Assertion failed<r><d>: <r>", true)
} else {
"Assertion failed: "
};
let _ = writer.write_all(text.as_bytes());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

Propagate the prefix write error.

Line 541 discards the writer.write_all result. If the stream fails, the function continues and can emit the assertion body without the required prefix. Propagate the error through the existing typed error path, or explicitly handle only an allowed stream error.

As per coding guidelines, I/O failures must be propagated explicitly instead of being discarded.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/jsc/ConsoleObject.rs` at line 541, Update the prefix-writing logic in the
surrounding assertion-output function so the result of
writer.write_all(text.as_bytes()) is handled explicitly. Propagate failures
through the function’s existing typed error path, preserving the behavior that
the assertion body is not emitted when writing the required prefix fails.

Source: Coding guidelines

}

if print_length > 0 {
format2(
level,
Expand Down