Commit 1df4781
Release typespec-ts emitter singleton state after
## What
Clears the emitter's process-wide singleton state at the end of
`$onEmit`:
- `ContextManager.clearContexts()` — drops the stored
`EmitContext`/`Program`, TCGC `SdkContext`, ts-morph `Project`, binder,
etc.
- `resetSdkTypesState()` — clears the module-level `emitQueue` /
`flattenPropertyModelMap` / `pagedModelsKeptPublic` collections.
## Why
These live at module scope, so after an emit they keep the most recently
emitted program graph reachable until the *next* emit overwrites them.
Clearing right after the emit finishes lets that memory be collected
sooner when many emits run in one process (test suites, watch mode).
## Scope / honesty
This is **bounded-to-one-program hygiene** — it is **not** a fix for an
unbounded leak. The actual unbounded leak behind
#4536 is upstream in the compiler's experimental
mutators (`seen` cache pins every mutated program's type-graph for the
process lifetime) and is tracked separately in microsoft/typespec#11120.
This PR is just good housekeeping on the typespec-ts side and is
independent of that fix.
Changeset is marked `internal` accordingly.
Related: #4536, microsoft/typespec#11120
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>$onEmit (#4787)1 parent 20de12e commit 1df4781
4 files changed
Lines changed: 55 additions & 2 deletions
File tree
- .chronus/changes
- packages/typespec-ts/src
- framework/hooks
Lines changed: 7 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
72 | 72 | | |
73 | 73 | | |
74 | 74 | | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
75 | 88 | | |
76 | 89 | | |
77 | 90 | | |
| |||
99 | 112 | | |
100 | 113 | | |
101 | 114 | | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
32 | 46 | | |
33 | 47 | | |
34 | 48 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
| 13 | + | |
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
46 | | - | |
| 46 | + | |
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
| |||
188 | 188 | | |
189 | 189 | | |
190 | 190 | | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
191 | 200 | | |
192 | 201 | | |
193 | 202 | | |
| |||
0 commit comments