Change:
When requests from shared process are redirected to main, the main request service is throwing errors for some valid requests. The same request is working when using browser XHR in shared process. To reproduce: Start VS Code using fresh user data dir and extensions dir Enable this setting - this is an internal developer setting, so you have to set manually in the file Turn on settings sync using your insiders settings sync service (Disable syncing settings) Extensions Syncing fails because of above error cc
What is the exact request URL and headers? We should be able to reproduce in a Electron fiddle maybe.
is an error from the chromium network stack, it happens when the request contains one of the following forbidden headers ;l=22-48
Here is the request info URL: Headers: Payload:
Are we setting the header ? The runtime will add that during payload upload, but if we override it then it will cause the above error.
Yes, we are
BTW we do the same request also in the renderer for querying extensions, so does removing the impacts the request in the renderer that uses XHR ?
Just tried removing the header and I am getting following error
The header will get by the runtime for payload requests, you should be able to confirm after removing the header. So, I don't think it will impact requests from renderer via XHR Hmm, why is zlib module being involved ? Are we using request API by any chance ?
We are not using request. Request service in main extends Node request service and pass electron net request API to Node request service for making request. See here: While handling the response, Node request service is checking for header and using zlib if it is set to . See here: May be main request service shall not use node request service at all?
Possibly an easier repro that was discovered by is calling the command also fails with the same network error. You should be able to do this via an extension
Can we now also make sure to go back to the Electron solution for maybe insiders to validate it works over some time?
Enabled -

Discussion:
export class RequestMainService extends NodeRequestService { override request(options: IRequestOptions, token: CancellationToken): Promise<IRequestContext> { <del> return super.request({ ...(options || {}), getRawRequest }, token); </del> <ins> return super.request({ ...(options || {}), getRawRequest, isChromiumNetwork: true }, token); </ins> } }

export interface NodeRequestOptions extends IRequestOptions { agent?: Agent; strictSSL?: boolean; <ins> isChromiumNetwork?: boolean; </ins> getRawRequest?(options: IRequestOptions): IRawRequestFunction; }

} else { let stream: streams.ReadableStreamEvents<Uint8Array> = res; <del> if (res.headers['content-encoding'] === 'gzip') { </del> <ins> // Responses from Electron net module should be treated as response // from browser, which will apply gzip filter and decompress the response // using zlib before passing the result to us. Following step can be bypassed // in this case and proceed further. // Refs https://source.chromium.org/chromium/chromium/src/+/main:net/url_request/url_request_http_job.cc;l=1266-1318 if (!options.isChromiumNetwork && res.headers['content-encoding'] === 'gzip') { </ins> stream = res.pipe(createGunzip()); }

req.setTimeout(options.timeout); } <ins> // Chromium will abort the request if forbidden headers are set. // Ref https://source.chromium.org/chromium/chromium/src/+/main:services/network/public/cpp/header_util.cc;l=14-48; // for additional context. if (options.isChromiumNetwork) { req.removeHeader('Content-Length'); } </ins> if (options.data) { if (typeof options.data === 'string') { req.write(options.data);