Skip to content

Blob.CreateAsync representing the standard constructor leaks an IJSObjectReference. #8

@KristofferStrube

Description

@KristofferStrube

The current implementation leaks a helper object that is never disposed of. We should dispose of it.

public static async Task<Blob> CreateAsync(IJSRuntime jSRuntime, IList<BlobPart>? blobParts = null, BlobPropertyBag? options = null)
{
    IJSObjectReference helper = await jSRuntime.GetHelperAsync();
    object?[]? jsBlobParts = blobParts?.Select<BlobPart, object?>(blobPart => blobPart.Part switch
        {
            byte[] part => part,
            Blob part => part.JSReference,
            _ => blobPart.Part
        })
        .ToArray();
    IJSObjectReference jSInstance = await helper.InvokeAsync<IJSObjectReference>("constructBlob", jsBlobParts, options);
    return new Blob(jSRuntime, jSInstance, new() { DisposesJSReference = true });
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions