-
Notifications
You must be signed in to change notification settings - Fork 31.3k
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
Don't leak RPC objects from API #115679
Comments
There are a tests that are skipped because they would be failing. Assigning folks
|
ping @eamodio |
ping @rebornix |
finished the comment API part. At the beginning I was marking This is a nice pattern to have, thanks for bringing this up @jrieken ❤️ . |
Commit: 5c31535ea8e984e249351f9fa56fb4990040cd61
SCM fixed with 85694fc |
@jrieken, do you want to keep the issue opened, or can we go ahead and close it? |
Thanks @lszomoru This can be closed 👯 I have added a few more tests recently but didn't find further RPC leaks. There are likely some more left but we can handle them case by case. |
This is a continuation of #115530 and an effort to make our API implementation more strict/locked-down.
Most of our API is implemented with the help of RPC calls to the renderer - that can be retrieving data or doing something. This is implemented with a protocol instance and objects that represent a slice of the API, aka proxies, like
MainThreadTextEditorsShape
. These proxies usually mirror the capabilities of the API but are often more powerful and therefore we should make sure these objects cannot be reached from the API.These leakages usually occur when having an API implemented as object which holds API-properties and internal/private-properties. Since non-native private properties aren't hidden to consumers an extension can reach them.
There are usually two ways of fixing this
#
. Those properties aren't accessible to outsiders but you should know that TypeScript down-level compiles native privates to a construct that uses weak map and is therefore significantly slower. This is a sample commit that hides a proxy by using a native private property: a01d16eNotebookEditorDecorationType
-type has now avalue
-property which is the API. All internals are hidden inside the containing class/scope. This has an additional benefit of TypeScript checking that your API isn't too large, e.g when using a literal for a certain API-type then the compiler will check that you have no extra properties. In the sample above having theNotebookEditorDecorationType.value.notDeclaredAPI :string
-property yield in a compile error.To test this I have added the
assertNoRpcFromEntry
andassertNoRpc
utilities which recursively crawl an API object and assert that no RPC object can be reached.These utilities run during teardown and on objects the API creates, like a status bar entry item. The checking for leaked RPC object does depend therefore on test coverage.
The text was updated successfully, but these errors were encountered: