Skip to content

Workspace settings are temporarily unavailable during implicit onLanguage activation after Reload Window #339092

Description

@TheEvilMandarin

Does this issue occur when all extensions are disabled?: Yes

  • VS Code Version: 1.125.0
  • OS Version: Windows 11 x64
  • Remote: SSH
  • Remote OS: Ubuntu 24.04 x64
  • Extension Host: remote (VS Code Server)

Description

An extension can be activated through an implicit onLanguage:<languageId> event while VS Code is restoring the previously opened editor after Developer: Reload Window.
At that moment:

  • vscode.workspace.workspaceFolders is already populated and contains the correct workspace folder;
  • vscode.workspace.getConfiguration(...).get(...) returns the default value instead of the value from .vscode/settings.json;
  • vscode.workspace.getConfiguration(...).inspect(...) reports the workspace value as undefined;
  • the workspace configuration becomes available only later, after activation has already completed.

The same problem does not occur when the extension is activated later through onStartupFinished. In that case, the value from .vscode/settings.json is already available when activate() is called.

Steps to Reproduce:

Reproduced in an Extension Development Host launched with --disable-extensions. The only active extension required for reproduction is the minimal development extension itself.

  1. Create a package.json file, specify the new language, and set activationEvents to onStartupFinished.
{
    "name": "vscode-config-repro",
    "displayName": "VS Code Configuration Repro",
    "description": "Minimal repro for workspace configuration loading",
    "version": "0.0.1",
    "engines": {
        "vscode": "^1.100.0"
    },
    "main": "./extension.js",
    "activationEvents": [
        "onStartupFinished"
    ],
    "contributes": {
        "languages": [
            {
                "id": "reprolang",
                "aliases": ["Repro Language"],
                "extensions": [".repro"],
                "configuration": "./language-configuration.json"
            }
        ],
        "configuration": {
            "title": "Configuration Repro",
            "properties": {
                "configRepro.testPath": {
                    "type": "string",
                    "default": "",
                    "scope": "window"
                }
            }
        }
    }
}
  1. Create an empty language-configuration.json.
  2. Create the extension.js file:
const vscode = require("vscode");

function dumpConfiguration(label) {
    const configuration =
        vscode.workspace.getConfiguration("configRepro");

    console.log(`\n========== ${label} ==========`);

    console.log("time:", new Date().toISOString());

    console.log(
        "workspaceFolders:",
        vscode.workspace.workspaceFolders?.map(
            folder => folder.uri.fsPath
        )
    );

    console.log(
        "activeTextEditor:",
        vscode.window.activeTextEditor?.document.uri.fsPath
    );

    console.log(
        "testPath:",
        configuration.get("testPath")
    );

    console.log(
        "inspect:",
        configuration.inspect("testPath")
    );

    console.log("==============================\n");
}

function activate(context) {
    dumpConfiguration("ACTIVATE");

    setTimeout(() => {
        dumpConfiguration("AFTER 0 MS");
    }, 0);

    setTimeout(() => {
        dumpConfiguration("AFTER 100 MS");
    }, 100);

    setTimeout(() => {
        dumpConfiguration("AFTER 500 MS");
    }, 500);

    setTimeout(() => {
        dumpConfiguration("AFTER 1000 MS");
    }, 1000);

    context.subscriptions.push(
        vscode.window.onDidChangeActiveTextEditor(() => {
            dumpConfiguration("ACTIVE EDITOR CHANGED");
        })
    );

    context.subscriptions.push(
        vscode.workspace.onDidChangeConfiguration(() => {
            dumpConfiguration("CONFIGURATION CHANGED");
        })
    );
}

function deactivate() {}

module.exports = {
    activate,
    deactivate
};
  1. The workspace configuration where we will test the extension: .vscode/settings.json
{
    "configRepro.testPath": "/THIS/IS/WORKSPACE/VALUE"
}
  1. Run Extension
  2. Open the .c file and run Developer: Reload Window.
  3. In OUTPUT - Extension Host the line was displayed:
    [info] ExtensionService#_doActivateExtension undefined_publisher.vscode-config-repro, startup: false, activationEvent: 'onStartupFinished'
  4. The "Debug Console" logs show that testPath is initialized immediately:
========== ACTIVATE ==========
time: 2026-10-01T12:03:35.256Z
workspaceFolders: (1) ['/home/anastasiia/projects/test']
activeTextEditor: /home/anastasiia/projects/test/main.c
testPath: /THIS/IS/WORKSPACE/VALUE
inspect: {key: 'configRepro.testPath', defaultValue: '', globalLocalValue: undefined, globalRemoteValue: undefined, globalValue: undefined, …}
==============================

========== AFTER 0 MS ==========
time: 2026-10-01T12:03:35.383Z
workspaceFolders: (1) ['/home/anastasiia/projects/test']
activeTextEditor: /home/anastasiia/projects/test/main.c
testPath: /THIS/IS/WORKSPACE/VALUE
inspect: {key: 'configRepro.testPath', defaultValue: '', globalLocalValue: undefined, globalRemoteValue: undefined, globalValue: undefined, …}
==============================
  1. Open the .repro file and run Developer: Reload Window.
  2. In OUTPUT - Extension Host the line was displayed:
    [info] ExtensionService#_doActivateExtension undefined_publisher.vscode-config-repro, startup: false, activationEvent: 'onLanguage:reprolang'
  3. The Debug Console shows that testPath is unavailable during activation and remains unavailable even after the active editor has been restored. It becomes available only on a subsequent onDidChangeConfiguration event:
========== ACTIVATE ==========
time: 2026-10-01T12:09:17.690Z
workspaceFolders: (1) ['/home/anastasiia/projects/test']
activeTextEditor: undefined
testPath: 
inspect: {key: 'configRepro.testPath', defaultValue: '', globalLocalValue: undefined, globalRemoteValue: undefined, globalValue: undefined, …}
==============================

========== AFTER 0 MS ==========
time: 2026-10-01T12:09:17.754Z
workspaceFolders: (1) ['/home/anastasiia/projects/test']
activeTextEditor: undefined
testPath: 
inspect: {key: 'configRepro.testPath', defaultValue: '', globalLocalValue: undefined, globalRemoteValue: undefined, globalValue: undefined, …}
==============================

========== AFTER 100 MS ==========
time: 2026-10-01T12:09:17.793Z
workspaceFolders: (1) ['/home/anastasiia/projects/test']
activeTextEditor: undefined
testPath: 
inspect: {key: 'configRepro.testPath', defaultValue: '', globalLocalValue: undefined, globalRemoteValue: undefined, globalValue: undefined, …}
==============================

========== CONFIGURATION CHANGED ==========
time: 2026-10-01T12:09:17.874Z
workspaceFolders: (1) ['/home/anastasiia/projects/test']
activeTextEditor: undefined
testPath: 
inspect: {key: 'configRepro.testPath', defaultValue: '', globalLocalValue: undefined, globalRemoteValue: undefined, globalValue: undefined, …}
==============================

========== ACTIVE EDITOR CHANGED ==========
time: 2026-10-01T12:09:18.139Z
workspaceFolders: (1) ['/home/anastasiia/projects/test']
activeTextEditor: /home/anastasiia/projects/test/test.repro
testPath: 
inspect: {key: 'configRepro.testPath', defaultValue: '', globalLocalValue: undefined, globalRemoteValue: undefined, globalValue: undefined, …}
==============================

========== CONFIGURATION CHANGED ==========
time: 2026-10-01T12:09:18.144Z
workspaceFolders: (1) ['/home/anastasiia/projects/test']
activeTextEditor: /home/anastasiia/projects/test/test.repro
testPath: /THIS/IS/WORKSPACE/VALUE
inspect: {key: 'configRepro.testPath', defaultValue: '', globalLocalValue: undefined, globalRemoteValue: undefined, globalValue: undefined, …}
==============================

========== AFTER 500 MS ==========
time: 2026-10-01T12:09:18.193Z
workspaceFolders: (1) ['/home/anastasiia/projects/test']
activeTextEditor: /home/anastasiia/projects/test/test.repro
testPath: /THIS/IS/WORKSPACE/VALUE
inspect: {key: 'configRepro.testPath', defaultValue: '', globalLocalValue: undefined, globalRemoteValue: undefined, globalValue: undefined, …}

Expected Behavior

Workspace configuration from .vscode/settings.json should be available when the extension's activate() function is invoked, regardless of whether activation is triggered by onLanguage:repro or onStartupFinished.

Alternatively, if workspace configuration is not guaranteed to be fully initialized at that point, the Extension API should provide a documented way to determine when the initial workspace configuration has finished loading.

Activity

  1. vs-code-engineering commented on Oct 1, 2026

    @vs-code-engineering
    Contributor

    Thanks for creating this issue! It looks like you may be using an old version of VS Code; the latest stable release is 1.140.0. Please try upgrading to the latest version and checking whether this issue remains.

    Happy Coding!

  2. TheEvilMandarin commented on Oct 1, 2026

    @TheEvilMandarin
    Author

    Thanks for creating this issue! It looks like you may be using an old version of VS Code; the latest stable release is 1.140.0. Please try upgrading to the latest version and checking whether this issue remains.

    Happy Coding!

    Version 1.140.0 – same problem.

    A similar configuration timing issue was discussed here: microsoft/vscode-discussions#1243
    In that discussion, it was noted that workspace-specific settings may be loaded after an extension has already been initialized due to VS Code's internal implementation. The discussion also raised the question of how an extension can determine when workspace settings have been fully loaded, but no corresponding issue appears to have been filed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions