Skip to content

Commit

Permalink
fix: Failsafe for NativeWriteStreamAdapter.Dispose
Browse files Browse the repository at this point in the history
  • Loading branch information
jeromelaban committed Jan 28, 2022
1 parent abc140d commit c8309a6
Showing 1 changed file with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Threading;
using System.Threading.Tasks;
using Uno.Foundation;
using Uno.Foundation.Logging;

namespace Uno.Storage.Streams.Internal
{
Expand Down Expand Up @@ -116,9 +117,16 @@ public override async Task WriteAsync(byte[] buffer, int offset, int count, Canc

protected override async void Dispose(bool disposing)
{
await ProcessPendingAsync();
// Close and dispose.
await WebAssemblyRuntime.InvokeAsync($"{JsType}.closeAsync('{_streamId}')");
try
{
await ProcessPendingAsync();
// Close and dispose.
await WebAssemblyRuntime.InvokeAsync($"{JsType}.closeAsync('{_streamId}')");
}
catch(Exception e)
{
this.Log().Warn("Failed to dispose NativeWriteStreamAdapter", e);
}
}

public async Task TruncateAsync(long length)
Expand Down

0 comments on commit c8309a6

Please sign in to comment.