Extensions can access sourcegraph.app.activeWindow.activeViewComponent.document before the document was synced to the extension host
Created by: felixfbecker
We currently sync the code views and document data separately:
Since communication with the extension host is (and always was) async, this can cause window data (i.e. the open editor) to be synced before the document that is open in that editor was synced.
This sometimes happens and causes the git-extras extension to throw when accessing activeViewComponent.document
: https://sourcegraph.com/github.com/sourcegraph/sourcegraph@758c376ba0981d315e29314797e4bfb56c8dd7ea/-/blob/shared/src/api/extension/api/documents.ts#L27:13
To reproduce it, delay the Observable of the document data:
@@ -107,7 +107,8 @@ export async function createExtensionHostClientConnection(
({ visibleViewComponents }) =>
visibleViewComponents && visibleViewComponents.map(({ item }) => item)
),
- distinctUntilChanged((a, b) => isEqual(a, b))
+ distinctUntilChanged((a, b) => isEqual(a, b)),
+ delay(100)
)
)