Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix: add error when destroying stream to generate close event even when the network connection is down #713

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

Open
pierreca wants to merge 3 commits into mqttjs:master
base: master
Choose a base branch
Loading
from pierreca:add-destroy-error

Conversation

@pierreca
Copy link

@pierreca pierreca commented Nov 7, 2017
edited by robertsLando
Loading

Fixes #710

When a stream is closed because the network connection, the close even fires correctly but after that if a user calls client.end() with a callback. that callback will never get called. As far as I understand, that is because the stream object will only fire another close event (which is required for the callback to be called) if stream.destroy(). is called with an error argument.

Tried to find a way to simulate the conditions in unit tests but could only repro the behavior with an actual network disconnection... so no specific test. existing tests don't seem to bother though.

Copy link

codecov bot commented Nov 7, 2017
edited
Loading

Codecov Report

Merging #713 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@ Coverage Diff @@
## master #713 +/- ##
======================================
 Coverage 92.9% 92.9% 
======================================
 Files 8 8 
 Lines 705 705 
 Branches 171 171 
======================================
 Hits 655 655 
 Misses 50 50
Impacted Files Coverage Δ
lib/client.js 96.31% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5d4d295...34873ca. Read the comment docs.

Copy link
Member

mcollina commented Nov 8, 2017

A unit test would be really good at this point. You can at least add a test that checks that an 'error' event is emitted on the stream.

Copy link
Member

mcollina commented Dec 9, 2017

Is there any update to this one?

Copy link
Author

@mcollina Sorry, slammed by work - I hope I can get back to that and add the test later, although I'm not sure I understand yet what exactly you think it'll test (I have to spend more time looking at it)

feel free to close if you don't like idling issues.

Copy link
Member

More or less I want a test that verified that 'error' is emitted on the stream if this.end(true) is passed in, and such callback is called.

Also, an example showing that such callback is indeed not called without this change.

Copy link
Contributor

@pierreca any chance on the conflicts being resolved? If not can this please be closed and the associated issue updated so someone else can take a stab at this.

Copy link
Member

@pierreca Could you have another look at this please? I'm tring to keep this library updated and I'm looking at open PR to see if there are some that could be merged. This looks ok to me

@robertsLando robertsLando changed the title (削除) Add error when destroying stream to generate close event even when the network connection is down (削除ここまで) (追記) fix: add error when destroying stream to generate close event even when the network connection is down (追記ここまで) Jun 27, 2023
@robertsLando robertsLando requested review from robertsLando and removed request for mcollina June 27, 2023 12:53
}
debug('_cleanUp :: (%s) :: destroying stream', this.options.clientId)
this.stream.destroy()
this.stream.destroy(newError('stream forcefully closed by the client'))
Copy link
Member

@robertsLando robertsLando Jun 27, 2023

Choose a reason for hiding this comment

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

Please add a test that reproduces the issue

Copy link
Member

It's not 100% clear to me why this happens. I mean based on nodejs docs the close event should be emitted every time destroy is called on a stream, it's just the error event that is emitted too if an error is passed. I keep this opened for now as I got some errors too in the past with client.end and I'm not sure if this could be a solution to that or nope

Copy link
Member

also please move the PR to main instead of master

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@robertsLando robertsLando robertsLando requested changes

Requested changes must be addressed to merge this pull request.

Assignees

No one assigned

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /