Skip to content

Persisting Code Lens Cache does not work in some cases #221005

Closed

Description

This seems very fishy:

Event.once(storageService.onWillSaveState)(e => {
if (e.reason === WillSaveStateReason.SHUTDOWN) {
storageService.store(key, this._serialize(), StorageScope.WORKSPACE, StorageTarget.MACHINE);
}
});

There is also WillSaveStateReason.NONE, in which case the event handler just unsubscribes because of the once.

I think this code should be like this:

const onWillSaveStateBecauseOfShutdown = Event.filter(storageService.onWillSaveState, e => e.reason === WillSaveStateReason.SHUTDOWN);
Event.once(onWillSaveStateBecauseOfShutdown)(e => {
	storageService.store(key, this._serialize(), StorageScope.WORKSPACE, StorageTarget.MACHINE);
});

I have a PR here: #221007

Activity

  1. added a commit that references this issue on Jul 8, 2024
    50d630c
  2. added
    unreleased
    on Jul 8, 2024
  3. jrieken commented on Jul 8, 2024

    @jrieken
    Contributor

    Nice find. Fix is ✅ tho I believe the original usage of once is because services didn't get disposed. So, once could also be replaced with a registered listener that gets disposed with the owning service

  4. added a commit that references this issue on Jul 8, 2024
    eb02531
  5. added
    insiders-released
    and removed
    unreleased
    on Jul 8, 2024
  6. added a commit that references this issue on Jul 10, 2024
    2c483c9
  7. locked and limited conversation to collaborators on Aug 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

insiders-released

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions