Skip to content

This fixes a leak in cleaning up RpcSessions objects - #69

Merged
gebner merged 4 commits into
leanprover:masterfrom
lovettchris:clovett/fix_leak
Nov 4, 2021
Merged

gebner merged 4 commits into
leanprover:masterfrom
lovettchris:clovett/fix_leak

Conversation

@lovettchris

Copy link
Copy Markdown

I think this explains some of the debug output we see after editing lean files for a while.

@gebner

gebner commented Nov 3, 2021

Copy link
Copy Markdown
Member

This PR also includes the commits from #63. Please rebase onto master.

@lovettchris

Copy link
Copy Markdown
Author

This PR also includes the commits from #63. Please rebase onto master.

fixed

// In that case we are either already connected or know we failed to do so, so don't want
// to mark as connecting.
if (this.#connecting.has(uri)) {
this.#connecting.set(uri, newSesh)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Does the comment match the code? You say "don't want to make as connecting" but then you go right ahead and set #connecting?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

"that case" is the else-branch afaict (where it is indeed marked as not connecting).

@gebner gebner left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The whole connected/connecting bookkeeping seems unnecessarily complicated (and error-prone as this PR shows). We could probably get away with a single #sessions map and a connected: Promise<{}> field in RpcSession.

// In that case we are either already connected or know we failed to do so, so don't want
// to mark as connecting.
if (this.#connecting.has(uri)) {
this.#connecting.set(uri, newSesh)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

"that case" is the else-branch afaict (where it is indeed marked as not connecting).

@gebner
gebner merged commit 5a5ca37 into leanprover:master Nov 4, 2021
@Vtec234

Vtec234 commented Nov 4, 2021

Copy link
Copy Markdown
Member

We could probably get away with a single #sessions map and a connected: Promise<{}> field in RpcSession.

I did try this idea when initially implementing RpcSessions and couldn't get it to work for reasons I don't remember, but which I think had to do with specifics of async/await in JS. I do agree that the #connecting invariants are overly complicated.

@lovettchris
lovettchris deleted the clovett/fix_leak branch November 4, 2021 22:38
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.

3 participants