Skip to content

vscode: fix local devel and remove disposables memory leak on server restrart #3725

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

Merged
merged 3 commits into from
Mar 26, 2020

Conversation

Veetaha
Copy link
Contributor

@Veetaha Veetaha commented Mar 25, 2020

No description provided.

@Veetaha Veetaha force-pushed the fix/vscode-properly-dispose-config branch 2 times, most recently from df2493d to e0e459a Compare March 25, 2020 18:59
}
}
await activate(context);
};
Copy link
Member

Choose a reason for hiding this comment

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

I'd rather keep this loop here, than wrap it into an abstraciton. This is another case where we do a horrible side-effectful thing, so not having to goto def to figure the control flow helps quite a bit. From the issue comment, seems like we need just to do ctx.subscriptions = []?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

subscriptions is marked as read-only, so it cannot be reassigned

Copy link
Member

Choose a reason for hiding this comment

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

            while (ctx.subscriptions.length > 0) {
                const sub = ctx.subscriptions.pop()!
                try {
                    sub.dispose();
                } catch (e) {
                    log.error(e);
                }
            }


if (disposable instanceof Array) {
while (disposable.length > 0) {
dispose(disposable.pop());
Copy link
Member

Choose a reason for hiding this comment

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

Disposing should always be wrapped in try/catch, so that panic in one dtor does not prevent other from firing.

See a fun bug in std about this issue: rust-lang/rust#67235

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a recursive call where try/catch is inside of it

Copy link
Member

Choose a reason for hiding this comment

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

Ahh.... yeah, this is exactly my point about control flow being non-obvious :D

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you want inline it here and in Map case?

Copy link
Member

Choose a reason for hiding this comment

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

I don't fully understand why we need anything beyond the original loop in the command.

Copy link
Contributor Author

@Veetaha Veetaha Mar 26, 2020

Choose a reason for hiding this comment

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

Just less boilerplate code... If you don't like it I'll remove

Veetaha added 3 commits March 26, 2020 23:42
The value of releaseTag is not undefined, but null in actual package.json
The memory leak was because on the server restrart the array of extensionContext.substiptions was not cleared
@Veetaha Veetaha force-pushed the fix/vscode-properly-dispose-config branch from e0e459a to 261ef1c Compare March 26, 2020 21:45
@matklad
Copy link
Member

matklad commented Mar 26, 2020

bors r+

@bors
Copy link
Contributor

bors bot commented Mar 26, 2020

@bors bors bot merged commit d2619bf into rust-lang:master Mar 26, 2020
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