microsoft / microsoft/ado-codespaces-auth

ReferenceError crash on sign-in: "Cannot access 'be' before initialization" (Temporal Dead Zone bug)

Open Beginner friendly
#35 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
10
Forks
8
Avg merge
8h 55m
Merged PRs (30d)
2

Description

Type: Bug

I asked Copilot to root cause the bug based on the minified stack and this is what it came back with. Seems plausible.

Bug

The extension crashes with a ReferenceError every time authentication fires (e.g. signing in with a Microsoft account). This happens consistently on recent VS Code Insiders builds.

Stack trace
[error] ReferenceError: Cannot access 'be' before initialization
    at …\ankitbko.vscode-pull-request-azdo-1.0.2\dist\extension.js:721:32618
    …
    at TP.$onDidChangeAuthenticationSessions (…extensionHostProcess.js:503:16838)
Root cause

In src/extension.ts, the init() function registers a vscode.authentication.onDidChangeSessions callback that references reposManager and reviewManagers:

vscode.authentication.onDidChangeSessions(async (e) => {
    if (e.provider.id === 'microsoft') {
        await reposManager.clearCredentialCache();   // ← references reposManager
        if (reviewManagers) {                        // ← references reviewManagers
            reviewManagers.forEach(reviewManager => reviewManager.updateState());
        }
    }
});

This registration happens before those variables are declared:

// onDidChangeSessions registered here (line ~50)
// ...
const reposManager = new RepositoriesManager(...);   // declared later (~line 80)
// ...
const reviewManagers = folderManagers.map(...);       // declared later (~line 90)

Because both are declared with const, they are in the Temporal Dead Zone until their declarations execute. In newer VS Code builds, the onDidChangeSessions event fires during initialization (before those const statements are reached), causing the ReferenceError.

Suggested fix

Move the onDidChangeSessions registration to after both reposManager and reviewManagers are initialized. The callback closure will then capture initialized bindings.

Environment
  • VS Code Insiders 1.99+ (April 2025 builds and later)
  • Extension version: 1.0.2
  • OS: Windows 11

Extension version: 1.2.1
VS Code version: Code - Insiders 1.115.0-insider (fc23f2d26631c6a2c4bf9f69506ea74c90a32804, 2026-03-31T17:13:42+01:00)
OS version: Windows_NT x64 10.0.26200
Modes:

System Info
Item Value
CPUs Intel(R) Xeon(R) Platinum 8370C CPU @ 2.80GHz (16 x 2793)
GPU Status 2d_canvas: unavailable_software
GPU0: VENDOR= 0x1414, DEVICE=0x008c [Microsoft Basic Render Driver], DRIVER_VENDOR=Google, DRIVER_VERSION=10.0.26100.7309
GPU1: VENDOR= 0x1414, DEVICE=0x008c [Microsoft Basic Render Driver], DRIVER_VERSION=10.0.26100.7309
GPU2: VENDOR= 0x1414, DEVICE=0x008c [Microsoft Basic Render Driver], DRIVER_VERSION=10.0.26100.7309
Machine model name:
Machine model version:
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: disabled_software
multiple_raster_threads: enabled_on
opengl: disabled_off
rasterization: disabled_software
raw_draw: disabled_off_ok
skia_graphite: disabled_off
trees_in_viz: disabled_off
video_decode: disabled_software
video_encode: disabled_software
webgl: unavailable_software
webgl2: unavailable_software
webgpu: unavailable_software
webnn: unavailable_software
Load (avg) undefined
Memory (System) 63.95GB (33.16GB free)
Process Argv --crash-reporter-id 22aa26ee-d46e-45b3-a0e3-4e89094f6674
Screen Reader no
VM 0%
A/B Experiments
vsliv368cf:30146710
pythonvspyt551:31249597
nativeloc1:31118317
dwcopilot:31158714
471b6256:31240254
dwoutputs:31242946
copilot_t_ci:31333650
g012b348:31231168
pythonrdcb7:31268811
pythonpcpt1cf:31399617
6518g693:31302842
63221493:31336333
envsactivate1:31349248
editstats-enabled:31346256
cloudbuttont:31366566
3efgi100_wstrepl:31403338
use-responses-api:31390341
ddidtcf:31398485
je187915:31401257
cmp-cht-control-294:31484965
metis_rerank_treatment1:31411021
cp_cls_t_966_ss:31454198
inlinechat_v2_hd992725:31445440
4je02754:31455664
8hhj4413:31478653
ge8j1254_inline_auto_hint_haiku:31426887
38bie571_auto:31487346
cp_cls_t_1081:31454832
conptydll_true:31485575
ia-use-proxy-models-svc:31446143
e9c30283:31453065
test_treatment2:31471001
idci7584:31454084
nes_chat_context_enabled:31451401
e3e4d672:31454087
showingstats:31457201
ei9d7968:31462942
534a6447_copy:31478741
7ef87755:31455235
nes-extended-on:31455475
de16b994:31458079
quick_suggest_off_75197330:31462668
89g7j272:31480197
hhf17803:31462392
bg_compact_t:31477450
t-some:31466503
7e187181:31482583
cpptoolsoff-v2:31475362
thinking_effort_h:31479457
i2gc6536:31472020
30450953:31486770
h08i8180:31475367
client_tst_t:31486874
po_com_t:31475410
ddid_c:31478205
getcmakediagnosticsoff:31487008
g_20_d1382936:31485443
file_logging_disabled:31485060
7df3h592:31486433
fixed-trtmt-prompt-cache:31486729
pro_ctrl:31484701
41e7a136_t:31485218

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in src/extension.ts and inspect init(), the onDidChangeSessions registration, and the later reposManager and reviewManagers declarations. Reproduce authentication initialization on VS Code Insiders and move the registration only after both managers are initialized; done means signing in no longer produces the ReferenceError.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript, vscode
Domain
authentication, desktop, tooling
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.