Commit f9422a9
fix: don't fail extension activation when a workspace folder has no dbt project
Production telemetry surfaced cluster `extensionActivationError` (83 unique
machines / 104 events / 24h, both 0.60.7 and 0.61.0) with the stack pinned
at:
Error: no projects found. retrying
at DBTWorkspaceFolder.retryWithBackoff
at async DBTWorkspaceFolder.discoverProjects
at async DBTProjectContainer.registerWorkspaceFolder
at async Promise.all (index 0)
at async DBTProjectContainer.initializeDBTProjects
at async DBTPowerUserExtension.activate
Distribution: ~95% darwin + linux, ~95% `core` integration mode, every
top-version contributing — consistent with the multi-root workspace
pattern common on dev machines, and inconsistent with a regression.
**Root cause.** VS Code's `workspaceContains:**/dbt_project.yml`
activation matches when ANY workspace folder contains a `dbt_project.yml`.
The extension then runs `discoverProjects` on EVERY workspace folder via
`Promise.all(folders.map(registerWorkspaceFolder))`. For a folder that
genuinely has no dbt project — typical for multi-root workspaces where a
sibling folder triggered activation — `findFiles` returns `[]` on every
attempt, `retryWithBackoff` exhausts after ~10s (5 attempts with 1+2+3+4
backoff), and the thrown `"no projects found. retrying"` propagates up
to the activate-level catch.
The visible damage isn't just the telemetry noise: the throw also
short-circuits the rest of `activate()`, so `statusBars.initialize()`
and the workspace-folder change listener never run. Users with a
mixed-folder workspace get a working dbt project for the folder that
matched, plus silently-degraded status-bar UX for the rest of the
session.
**Fix.** In `retryWithBackoff`, treat a consistently-empty result after
the retry budget as legitimately empty and return `[]` instead of
throwing. The retry schedule and the empty/non-empty differentiation
are unchanged — only the terminal disposition. Real errors from `fn()`
(permission failures, malformed pattern, indexer crashes) still throw
after retries, preserving the existing escalation for non-empty failure
modes. The constructor's `createConfigWatcher` keeps watching for
`dbt_project.yml` creation in this folder, so a project added later is
still picked up.
This also restructures the loop so empty results are handled by normal
control flow rather than via a thrown-and-caught sentinel error, which
is cleaner and removes the previously-unreachable
`"no projects found after maximum retries"` throw at the bottom of the
function.
**Verification.** Adds `src/test/suite/discoverProjectsRepro.test.ts`
with four cases that instantiate the real `DBTWorkspaceFolder` and stub
only `workspace.findFiles`:
1. Consistently empty `findFiles` → `discoverProjects` resolves
cleanly (was: rejects after ~10s).
2. Retry budget unchanged at ~10s — backoff schedule identical to
pre-fix.
3. Multi-root `Promise.all([happy, empty])` resolves successfully —
reproduces the production "Promise.all (index 0)" stack frame and
proves the fix unblocks the rest of `activate()`.
4. `findFiles` rejecting (e.g. EACCES) still throws after 5 retries —
guards against accidentally swallowing genuine errors.
Pre-fix output captured at
`screenshots/no-projects-found-investigation/repro-output.txt`; post-fix
at `screenshots/no-projects-found-investigation/after-fix-repro.txt`.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 68ef665 commit f9422a9
2 files changed
Lines changed: 182 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
94 | 94 | | |
95 | 95 | | |
96 | 96 | | |
97 | | - | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
98 | 105 | | |
99 | 106 | | |
100 | 107 | | |
101 | 108 | | |
102 | 109 | | |
103 | | - | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
104 | 113 | | |
105 | | - | |
106 | 114 | | |
| 115 | + | |
| 116 | + | |
107 | 117 | | |
108 | 118 | | |
109 | 119 | | |
110 | 120 | | |
111 | 121 | | |
112 | 122 | | |
113 | 123 | | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
114 | 135 | | |
115 | 136 | | |
116 | | - | |
| 137 | + | |
117 | 138 | | |
118 | 139 | | |
119 | | - | |
| 140 | + | |
120 | 141 | | |
121 | 142 | | |
122 | 143 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
0 commit comments