networkDiagnosticsService.ts ×11

Frontier kind: Joint frontier

unlabeled · c_1e14c2889c4f

1 test · 12607 LOC · 68 files · introduces 1 test · 83 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
11 ranges83 lines · 1 files
Tests
1 test

Contains — complete concept membership

All code (extent)
1866 ranges12607 lines · 68 files · Browse complete extent
All tests (intent)
1 testBrowse complete intent

Neighbourhood graph

The orange circle is the focus. Violet and green circles are every ancestor and descendant, broader and narrower, at any distance; blue squares and pink diamonds are the introduced files and exact introduced tests of every visible concept, not only the focus's. Arrows point from broader to narrower concepts and bridge only concepts omitted from this view. Undirected links show source or test introduction. Concept and file size follows LOC; exact test nodes use test-count units.

Introduced files, introduced tests, and structurally relevant concept specialization

In the embedded map, ordinary wheel input scrolls the page; use the visible controls to zoom and drag to pan. Open the full-screen map for canvas navigation: wheel pans, Ctrl/Command plus wheel zooms, and arrow keys pan when this region is focused. On touch screens, open the full-screen map to pan or pinch. If JavaScript or WebGL is unavailable, use the native relationship evidence on this page.

Graph controls are ready.

Interactive rendering requires JavaScript and WebGL. Use the native relationship evidence on this page while the interactive map is unavailable.

Native relationship evidence

Every exact file and test below is linked only from the concept that introduces it.

Introduced tests

Every collected test enters the hierarchy at exactly one concept.

1 test introduced at this concept.

Introduced code

Every collected source range enters the hierarchy at exactly one concept.

1 file ranked by introduced lines: 83 introduced LOC across 11 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/platform/agentHost/node/networkDiagnosticsService.ts 83 introduced LOC · 11 ranges

Open complete file

54
55 constructor(
56 > @IRequestService private readonly _requestService: IRequestService, networkDiagnosticsService.ts
57 > @IAgentHostProxyResolver private readonly _proxyResolver: IAgentHostProxyResolver,
58 > @IConfigurationService private readonly _configurationService: IConfigurationService,
59 > @IProductService private readonly _productService: IProductService,
60 > @ILogService private readonly _logService: ILogService,
61 > ) { }
62
63 async getInfo(endpoints: readonly IAgentHostNetworkEndpoint[], account?: string): Promise<IAgentHostNetworkDiagnosticsInfo> {
99 */
100 async fetch(url: string): Promise<IAgentHostNetworkFetchResult> {
101 > const target = new URL(url); networkDiagnosticsService.ts
102 > const host = target.hostname;
103 >
104 > // DNS: resolve both address families so a host that only answers on one is visible.
105 > const [dnsIpv4, dnsIpv6] = await Promise.all([
106 > resolveDns(host, 4),
107 > resolveDns(host, 6),
108 > ]);
109 >
110 > // Proxy resolution (for reporting; IRequestService resolves its own proxy internally).
111 > let proxyUrl: string | undefined;
112 > try {
113 > proxyUrl = await this._proxyResolver.resolveProxy(url);
114 > } catch (err) {
115 this._logService.debug(`[AgentHost] Network diagnostics: proxy resolution for ${url} failed: ${errorMessage(err)}`);
116 }
118 > const base = {
119 > url,
120 > proxyUrl,
121 > dnsIpv4, dnsIpv6,
122 > };
123 >
124 > // Reachability: a GET through IRequestService, which applies VS Code's proxy,
125 > // strictSSL, and certificate handling — the path the rest of VS Code uses.
126 > const probeStart = Date.now();
127 > try {
128 > const context = await this._requestService.request({
129 > url,
130 > type: 'GET',
131 > timeout: PROBE_TIMEOUT_MS,
132 > callSite: NO_FETCH_TELEMETRY,
133 > }, CancellationToken.None);
134 const body = (await streamToBuffer(context.stream)).toString();
135 return {
136 ...base,
137 statusCode: context.res.statusCode,
138 > body: body.length > MAX_BODY_CHARS ? body.slice(0, MAX_BODY_CHARS) : body, networkDiagnosticsService.ts
139 > durationMs: Date.now() - probeStart,
140 > };
141 > } catch (err) {
142 > return {
143 > ...base,
144 > error: errorMessage(err),
145 > durationMs: Date.now() - probeStart,
146 > };
147 > }
148 > }
149 }
150
151 > function dnsLookup(host: string, family: 4 | 6): Promise<string> { networkDiagnosticsService.ts
152 > return new Promise((resolve, reject) => {
153 > lookup(host, { family }, (err, address) => err ? reject(err) : resolve(address));
154 > });
155 > }
156
157 > async function resolveDns(host: string, family: 4 | 6): Promise<IAgentHostDnsResult> { networkDiagnosticsService.ts
158 > const start = Date.now();
159 > try {
160 > const address = await withTimeout(dnsLookup(host, family), PROBE_TIMEOUT_MS);
161 > return { address, durationMs: Date.now() - start };
162 > } catch (err) {
163 return { durationMs: Date.now() - start, error: errorMessage(err) };
164 }
166
167 > function withTimeout<T>(promise: Promise<T>, ms: number): Promise<T> { networkDiagnosticsService.ts
168 > return new Promise<T>((resolve, reject) => {
169 > const timer = setTimeout(() => reject(new Error(`Timed out after ${ms / 1000}s`)), ms);
170 > promise.then(
171 > value => { clearTimeout(timer); resolve(value); },
172 > err => { clearTimeout(timer); reject(err); },
173 > );
174 > });
175 > }
176
177 > function errorMessage(error: unknown): string { networkDiagnosticsService.ts
178 > const seen = new Set<unknown>();
179 > function collect(error: unknown): string {
180 > if (seen.has(error)) {
181 return '';
182 }
183 > seen.add(error); networkDiagnosticsService.ts
184 > if (!(error instanceof Error)) {
185 return String(error);
186 }
187 > const details = [ networkDiagnosticsService.ts
188 > error.cause ? collect(error.cause) : '',
189 > ...(error instanceof AggregateError ? error.errors.map(collect) : []),
190 > ].filter(Boolean).join(', ');
191 > return details ? `${error.message}: ${details}` : error.message;
192 > }
193 > return collect(error);
194 > }