Skip to content

Debugger stuck when write to IO #358

@newptcai

Description

@newptcai

I have the following function which I tried to debug

"""
    encode_file_to_base64(file_path)

Encodes the content of a file to a Base64 string along with its MIME type.

# Arguments
- `file_path`: Path to the file to be encoded.

# Returns
A tuple containing the MIME type and the Base64-encoded string.

"""
function encode_file_to_base64(file_path)
    @debug "Encoding $file_path to Base64"

    # Read the file content
    file_content = read(file_path)

    @debug "File content read: $(length(file_content)) bytes"

    # Determine the MIME type based on file extension
    file_extension = splitext(file_path)[2]
    mime_type = mime_from_extension(file_extension)

    @debug "MIME type: $mime_type"

    # Create a base64-encoded string
    io = IOBuffer()
    iob64_encode = Base64EncodePipe(io)
    write(iob64_encode, file_content)
    close(iob64_encode)
    base64_encoded = String(take!(io))

    @debug "Base64 encoded: $(length(base64_encoded)) bytes"

    return (mime_type, base64_encoded)
end

When debugger reaches the line write(iob64_encode, file_content) and I hit u, the debugger never reaches the next line.

Running the code without debugger does not get stuck there.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions