Skip to content

Fix Stream Detection#214

Open
kierangraham wants to merge 5 commits into
jimhigson:masterfrom
kierangraham:fix/stream-detection
Open

Fix Stream Detection#214
kierangraham wants to merge 5 commits into
jimhigson:masterfrom
kierangraham:fix/stream-detection

Conversation

@kierangraham

Copy link
Copy Markdown

Fixes an issue where oboe would fail to correctly detect that an object was a stream.

Previously, o instanceof Object was used to do object detection. Based in the info from this StackOverflow post it's more reliable to do something like object !== null && typeof object === "object".

That's the change that this PR makes as in a TypeScript project I'm working on for some reason the isStream method returned false when reading a file from S3 and unzipping it, which returned a DuplexWrapper stream object.

I've tried to create a test case for this but couldn't quite reproduce it properly; even when I create a simple test to check if my stream object is an instanceof Object it turns out to be true. So I'm not entirely sure what's going on specific to this project that makes the streams in Node (12) not an instance of Object.

In any case, this change still fixes my issue even though I don't completely understand why a stream wouldn't be instanceof Object and the method of checking that is improved and causes no other side effects, with the full suite passing.

Maybe someone with more insights can explain what could be happening.

@kierangraham

Copy link
Copy Markdown
Author

@jimhigson would you be able to give this a review? 🙏

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

Successfully merging this pull request may close these issues.

1 participant