diff --git a/swift/mcap/MCAPWriter.swift b/swift/mcap/MCAPWriter.swift index 8232b0203b..d120c67053 100644 --- a/swift/mcap/MCAPWriter.swift +++ b/swift/mcap/MCAPWriter.swift @@ -161,6 +161,9 @@ public final class MCAPWriter { } } else { message.serialize(to: &buffer) + if buffer.count >= options.chunkSize { + await _flush() + } } } @@ -219,6 +222,7 @@ public final class MCAPWriter { let chunkStartOffset = _position() chunk.serialize(to: &buffer) + await _flush() let messageIndexStartOffset = _position() var messageIndexOffsets: [ChannelID: UInt64] = [:]