-
Notifications
You must be signed in to change notification settings - Fork 286
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
Drain data from response in browserify environment #656
Conversation
11dd6c5
to
16b709b
Compare
src/main/minio.js
Outdated
response.socket.end() | ||
} else { | ||
// For browserify environment | ||
response.on('data', ()=>{}) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.)
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 ?
There was a problem hiding this comment.
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.
There was a problem hiding this 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
.
@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. |
good catch @kaankabalak, I will fix it. |
16b709b
to
e95e70a
Compare
There was a problem hiding this 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
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. |
Browser is actually officially supported, lack of docs is perhaps an oversight. |
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. |
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. |
b90efa8
to
099cd1d
Compare
I think we not only need to discuss it further but also test it and then document it. @abperiasamy |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM & tested
099cd1d
to
7dc5cb2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
It was decided that we will properly document, test this and support browser usage for minio-js. |
@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. |
fixes #654