Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drain data from response in browserify environment #656

Merged

Conversation

krishnasrinivas
Copy link
Contributor

fixes #654

response.socket.end()
} else {
// For browserify environment
response.on('data', ()=>{})
Copy link
Member

Choose a reason for hiding this comment

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

wouldn't this work for nodejs as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it will work, but socket.end() would be the right way to close the socket. response.on('data', ()=>{}) is a workaround on browser. So it is better to do it this way, I think. (Though I see the advantage of having response.on('data', ()=>{}) for both node and browser is that you don't need if/else statements.)

Copy link
Member

@harshavardhana harshavardhana Dec 16, 2017

Choose a reason for hiding this comment

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

yes that is what i was thinking. Accessing socket feels too low level IMO. You let nodejs runtime to do that for you but our approach is just to drain the response body.

Copy link
Member

Choose a reason for hiding this comment

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

yes that is what i was thinking. Accessing socket feels too low level IMO. You let nodejs runtime to do that for you but our approach is just to drain the response body.

do you mean nodejs runtime will automatically close underlying socket when it frees response ?

Copy link
Member

Choose a reason for hiding this comment

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

Well that is what I would expect. That would allow underlying http to reuse the socket.

Copy link
Contributor

@kaankabalak kaankabalak left a comment

Choose a reason for hiding this comment

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

Wouldn't the response.socket.end() on line 1381 also return the same error?

Update: When I tried running the statObject function that encloses the response.socket.end() method mentioned above in the browser (Firefox 57.0.1), it indeed returns a similar error with the message TypeError: response.socket is undefined.

@vadmeste
Copy link
Member

@krishnasrinivas, is there a sample project which uses minio-js in a browser ? I am not able to find one.

@harshavardhana
Copy link
Member

@krishnasrinivas, is there a sample project which uses minio-js in a browser ? I am not able to find one.

@vadmeste https://gist.github.com/harshavardhana/9f8f2236dee975fb70edbec5db14fd67 here is a sample work.

@krishnasrinivas
Copy link
Contributor Author

Wouldn't the response.socket.end() on line 1381 also return the same error?

good catch @kaankabalak, I will fix it.

Copy link
Contributor

@kaankabalak kaankabalak left a comment

Choose a reason for hiding this comment

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

Test that failed previously runs fine now, LGTM

@vadmeste
Copy link
Member

vadmeste commented Dec 16, 2017

Do we support officially support browser ? Because there are no documentation about how to generate minio-browser.js (gulp browserify). I can do that in a separate PR.

@harshavardhana
Copy link
Member

Browser is actually officially supported, lack of docs is perhaps an oversight.

@deekoder
Copy link
Contributor

I don't think its an oversight. I don't think we are officially supporting it. But users are using it on the client side anyway.

@harshavardhana
Copy link
Member

We are actually officially supporting it, I don't remember when we decided not to @deekoder . Browser side support was added to comply with aws-sdk-js behavior long time ago.

We just have to document it how to use it though.

@krishnasrinivas krishnasrinivas force-pushed the no-socketend-browserify branch 2 times, most recently from b90efa8 to 099cd1d Compare December 18, 2017 20:33
@deekoder
Copy link
Contributor

I think we not only need to discuss it further but also test it and then document it. @abperiasamy

vadmeste
vadmeste previously approved these changes Dec 20, 2017
Copy link
Member

@vadmeste vadmeste left a comment

Choose a reason for hiding this comment

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

LGTM & tested

Copy link
Member

@vadmeste vadmeste left a comment

Choose a reason for hiding this comment

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

LGTM

@harshavardhana
Copy link
Member

It was decided that we will properly document, test this and support browser usage for minio-js.

@krishnasrinivas
Copy link
Contributor Author

@harshavardhana we can merge this right? So that @gusajz and other browserified minio-js users are not blocked from our testing efforts. Anyway till we we document that it is supported, it will not be supported.

@harshavardhana
Copy link
Member

@harshavardhana we can merge this right? So that @gusajz and other browserified minio-js users are not blocked from our testing efforts. Anyway till we we document that it is supported, it will not be supported.

It was decided that we merge this and move forward with documenting/testing subsequently.

@krishnasrinivas krishnasrinivas merged commit efb52c6 into minio:master Jan 4, 2018
dingjs pushed a commit to dingjs/minio-js that referenced this pull request Jan 7, 2018
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.

Release 3.2.3 doesn't work in the browser
5 participants