Skip to content

Commit

Permalink
fix(react-native): fix for "<Intermediate Value>.stream is not a func…
Browse files Browse the repository at this point in the history
…tion" errors in React Native (#1156)
  • Loading branch information
crutchcorn authored and billiegoose committed Dec 17, 2020
1 parent 153679f commit 03846e1
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/utils/deflate.js
Expand Up @@ -22,6 +22,8 @@ async function browserDeflate(buffer) {
function testCompressionStream() {
try {
const cs = new CompressionStream('deflate')
// Test if `Blob.stream` is present. React Native does not have the `stream` method
new Blob([]).stream()
if (cs) return true
} catch (_) {
// no bother
Expand Down

1 comment on commit 03846e1

@inverted-capital
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey that stream needs to be closed or else it is dangling. Is it feasible to check for the stream key on the new Blob([]) object rather than creating the stream ?

I don't have a react native environment to test this out on.

Creating a ReadableStream is a heavy operation and the teardown using .cancel() is a promise, so it will take an indeterminate time to close, and should be avoided if we can.

Please sign in to comment.