Skip to content
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

Debugger stuck when write to IO #358

Open
newptcai opened this issue Dec 22, 2024 · 0 comments
Open

Debugger stuck when write to IO #358

newptcai opened this issue Dec 22, 2024 · 0 comments

Comments

@newptcai
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant