Commit 3bfb235
committed
perf(linter): Implement streaming diagnostics for tsgolint instead of waiting for output to finish (#13098)
This PR resolves the TODO comment at line 126 in `apps/oxlint/src/tsgolint.rs` by implementing streaming diagnostics for tsgolint instead of waiting for the entire process to complete.
## Problem
Previously, the tsgolint integration would:
1. Spawn the tsgolint process
2. Wait for the entire process to complete using `child.wait_with_output()`
3. Parse all output at once
4. Send all diagnostics to the diagnostic service
This approach meant users had to wait for tsgolint to process all files before seeing any feedback, which could be slow for large codebases.
## Solution
The implementation now streams diagnostics as they are emitted:
1. **Streaming stdout reader**: Reads from the tsgolint process stdout in 4KB chunks as data becomes available
2. **Incremental message parsing**: Uses the existing binary protocol parser to process complete messages as they arrive in the buffer
3. **Immediate diagnostic sending**: Sends diagnostics to the diagnostic service via the `error_sender` channel as soon as they are parsed
4. **Proper buffering**: Keeps incomplete messages in the buffer for the next iteration to handle message boundaries correctly
## Key Changes
- Replaced `child.wait_with_output()` with streaming stdout reading in a separate thread
- Added incremental buffer processing that identifies complete messages using the binary protocol format
- Maintained backward compatibility - all existing tests pass
- Removed unused `parse_tsgolint_output()` function since parsing now happens incrementally
- Added proper error handling for both process exit status and stdout processing
## Benefits
- **Faster feedback**: Users see diagnostics as soon as tsgolint emits them, rather than waiting for completion
- **Better user experience**: Especially beneficial for large codebases where tsgolint processing takes significant time
- **Same reliability**: All existing functionality and error handling is preserved
- **No breaking changes**: The API and behavior remain the same from the user's perspective
The streaming implementation provides a more responsive experience while maintaining full compatibility with existing tsgolint integration.
<!-- START COPILOT CODING AGENT TIPS -->
---
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click [here](https://survey.alchemer.com/s3/8343779/Copilot-Coding-agent) to start the survey.1 parent 7e15446 commit 3bfb235
1 file changed
+122
-82
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
117 | 117 | | |
118 | 118 | | |
119 | 119 | | |
120 | | - | |
121 | | - | |
122 | | - | |
123 | | - | |
124 | | - | |
125 | | - | |
126 | | - | |
127 | | - | |
128 | | - | |
129 | | - | |
130 | | - | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
131 | 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 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
132 | 219 | | |
133 | | - | |
134 | | - | |
135 | | - | |
136 | | - | |
137 | | - | |
138 | | - | |
139 | | - | |
140 | | - | |
141 | | - | |
142 | | - | |
143 | | - | |
144 | | - | |
145 | | - | |
146 | | - | |
147 | | - | |
148 | | - | |
149 | | - | |
150 | | - | |
151 | | - | |
152 | | - | |
153 | | - | |
154 | | - | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
155 | 224 | | |
156 | | - | |
157 | | - | |
158 | | - | |
159 | | - | |
160 | | - | |
161 | | - | |
162 | | - | |
163 | | - | |
164 | | - | |
165 | | - | |
166 | | - | |
167 | | - | |
168 | | - | |
169 | | - | |
170 | | - | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
171 | 229 | | |
| 230 | + | |
172 | 231 | | |
173 | | - | |
174 | | - | |
175 | | - | |
176 | | - | |
177 | | - | |
178 | | - | |
179 | | - | |
180 | | - | |
181 | | - | |
182 | | - | |
183 | | - | |
| 232 | + | |
| 233 | + | |
184 | 234 | | |
185 | | - | |
186 | | - | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
187 | 242 | | |
188 | | - | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
189 | 247 | | |
190 | 248 | | |
191 | 249 | | |
| |||
304 | 362 | | |
305 | 363 | | |
306 | 364 | | |
307 | | - | |
| 365 | + | |
308 | 366 | | |
309 | 367 | | |
310 | | - | |
311 | | - | |
312 | | - | |
313 | | - | |
314 | | - | |
315 | | - | |
316 | | - | |
317 | | - | |
318 | | - | |
319 | | - | |
320 | | - | |
321 | | - | |
322 | | - | |
323 | | - | |
324 | | - | |
325 | | - | |
326 | | - | |
327 | | - | |
328 | 368 | | |
329 | 369 | | |
330 | 370 | | |
| |||
0 commit comments