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

Make sure BattleStream only calls _destroy once #5382

Merged
merged 1 commit into from
Mar 30, 2019

Conversation

scheibo
Copy link
Contributor

@scheibo scheibo commented Mar 30, 2019

Fixes Error: Push after end of read stream from #5370 (comment).

this.push(null) triggers this._end() which calls this._destroy() already.

This was fine before (though redundant), but no longer null-ing out this.battle (either by default or through {retainBattle: true}) causes the double _destroy to become a problem because the if (this.battle) this.battle.destroy() check no longer works, and Battle#destroy() is not meant to be called more than once.

@scheibo scheibo closed this Mar 30, 2019
@Zarel
Copy link
Member

Zarel commented Mar 30, 2019

I guess this turned out to be more complicated than you expected?

@scheibo scheibo reopened this Mar 30, 2019
@scheibo
Copy link
Contributor Author

scheibo commented Mar 30, 2019

I guess this turned out to be more complicated than you expected?

OK, so whats confusing me is this._end also does a this.push(null), which scared me and made me think my reasoning about this.push(null) triggering this._end() was wrong, but I looked it over and that still appears to be the case.

Because there's no way to switch an in progress PR to a draft to indicate I was having second thoughts I closed to try and prevent an accidental merge for code I wasn't sure about.

if (this.battle) {
this.battle.destroy();
}
this.battle = null;
Copy link
Member

Choose a reason for hiding this comment

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

Wasn't this line also removed? Am I thinking of a different stream or did this never get merged or what?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're thinking of c45ff0e on #5370 which has not been merged into HEAD yet. I just redid those changes on this PR because its not like they were specific to #5370, they just were discovered there, and landing them earlier seems useful given all my PRs involving the harness seem to get bogged down :)

@Zarel Zarel merged commit 1c14764 into smogon:master Mar 30, 2019
@scheibo scheibo deleted the push-end branch April 3, 2019 02:47
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