Skip to content

Extension code cache does not get invalidated #78542

Closed

Description

Distilled from #75642 (comment)

Create an extension at e.g. c:\Users\alex\.vscode-insiders\extensions>

  • package.json:
{
    "name": "75642",
    "publisher": "alex",
    "version": "1.0.0",
    "engines": {
        "vscode": "^1.31.0"
    },
    "activationEvents": ["*"],
    "main": "index.js"
}
  • index.js:
const vscode = require('vscode');

exports.activate = function() {
    const transparentRed = vscode.window.createTextEditorDecorationType({
        backgroundColor: '#ff000088'
    });
    const red = vscode.window.createTextEditorDecorationType({
        backgroundColor: '#ff0000ff'
    });

    const decorate = function() {
        const editor = vscode.window.activeTextEditor;
        if (!editor) {
            return;
        }
        editor.setDecorations(transparentRed, [new vscode.Range(215681, 0, 215681, 6)]);
        editor.setDecorations(red, [new vscode.Range(215683, 2, 215683, 7)]);
    }
    vscode.window.onDidChangeActiveTextEditor(decorate);
    decorate();
};
  • Run a new insiders window and open a file with 215681 lines or tweak the numbers:
    image

Observe (via the inspector) the opacity for the first decoration is 0.533 which is 136/255 (drive by the 88 opacity).

Wait for a while and observe the cache data file:
image

image

  • Open index.js in another VSCode window and change the opacity in the first color from 88 to 33

  • Reload the second window

  • Observe the color does not change because the cached data is not invalidated.

Activity

  1. jrieken commented on Aug 6, 2019

    @jrieken
    Contributor

    The caching relies on file names changing (commit hash for our sources, version ids for extension sources). When files change without changing their path we rely on v8 rejecting the data. This case seems to trigger none of the bail out mechanisms: file path doesn't change, v8 doesn't reject...

  2. added
    bug
    on Aug 6, 2019
  3. jrieken commented on Aug 6, 2019

    @jrieken
    Contributor

    Now, a hash is used verify the cached data still matches the sources. Tho, this happens after the fact and only on the console.

  4. added
    verified
    on Aug 28, 2019
  5. locked and limited conversation to collaborators on Sep 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bugverified

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions