Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,10 @@ public struct StandardIOMessageConnection: MessageConnection {

// Read the JSON payload.
let count = Int(UInt64(littleEndian: header))
// Empty message is a termination signal.
Copy link
Member

Choose a reason for hiding this comment

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

Is the compiler explicitly sending a message with header == 0 to indicate that the plugin process should exit?

if count == 0 {
return nil
}
Copy link
Member Author

@rintaro rintaro Oct 10, 2025

Choose a reason for hiding this comment

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

FWIW, not returning nil is still safe. try _read(into: data) is no-op, and JSON.decode() would throw an Error, then the caller would exit(1). This change just make it graceful immediate exit(0)

let data = UnsafeMutableRawBufferPointer.allocate(byteCount: count, alignment: 1)
defer { data.deallocate() }
try _read(into: data)
Expand Down