openpgpjs / web-stream-tools

Convenience functions for reading, transforming and working with WhatWG Streams
MIT License
27 stars 15 forks source link

Fix (temporary): stream.cancel race condition #31

Closed larabr closed 1 year ago

larabr commented 1 year ago

Stream was not always cancelled when input.cancel's promise resolved; the problem was observed in the OpenPGP.js tests on firefox, as part of the changes in https://github.com/openpgpjs/openpgpjs/pull/1645.

We could repro the problem also using lib versions < 0.0.12, namely before the changes in https://github.com/openpgpjs/web-stream-tools/commit/9bdfe7917b583eb53b51062b85cd750062793c9c.

This is a temporary fix: since stream cancellation is not a performance-sensitive operation, we've opted to add a small timeout to the promise. We'll have to investigate why the issue comes up in the first place.