Skip to content

emit 'close' event after core has been closed. closed (#154).#157

Merged
mafintosh merged 1 commit intoholepunchto:masterfrom
rhodey:emit-close-event
May 29, 2018
Merged

emit 'close' event after core has been closed. closed (#154).#157
mafintosh merged 1 commit intoholepunchto:masterfrom
rhodey:emit-close-event

Conversation

@rhodey
Copy link
Copy Markdown

@rhodey rhodey commented May 23, 2018

Emit close event after core has been closed. Maybe we don't want to emit close if the close callback is invoked with an error, I'm not sure. In my situation I think I prefer emitting the event even if close failed, because close will probably just keep failing again, and I'm more interested in "when is is OK to exit".

Addresses issue report #154.

index.js Outdated
self.readable = false
self._storage.close(cb)
self._storage.close(function (err) {
self.emit('close')
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

should only be emitted if no error occured during storage.close. Also mind adding a flag '.closed` or similar so we don't emit this twice?

@mafintosh
Copy link
Copy Markdown
Contributor

@rhodey nice catch! take a look at my comment.

@rhodey
Copy link
Copy Markdown
Author

rhodey commented May 29, 2018

@mafintosh thanks for the comments :) what do you think about my .closed logic? do we wanna just prevent the emitting of the event if it has been emitted before, or should we no-op the whole method if it has already been called?

@mafintosh
Copy link
Copy Markdown
Contributor

This looks good to me

@mafintosh
Copy link
Copy Markdown
Contributor

@rhodey oh mind adding a test? then we can't a regression in the future

@rhodey rhodey force-pushed the emit-close-event branch from a5a7a26 to 90595bd Compare May 29, 2018 17:50
@mafintosh mafintosh merged commit 792fb24 into holepunchto:master May 29, 2018
@mafintosh
Copy link
Copy Markdown
Contributor

6.15.0

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.

2 participants