-
Notifications
You must be signed in to change notification settings - Fork 179
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
this[kClient].connect is not a function #444
Comments
corepack is part of sudo apt install nodejs=20.11.1-1nodesource1 |
Yes, I am also using nodejs distributed by NodeSource. |
Probably import diff --git a/sources/httpUtils.ts b/sources/httpUtils.ts
index e995d1e..b856099 100644
--- a/sources/httpUtils.ts
+++ b/sources/httpUtils.ts
@@ -100,11 +100,7 @@ async function getProxyAgent(input: string | URL) {
if (!proxy) return undefined;
- // Doing a deep import here since undici isn't tree-shakeable
- const {default: ProxyAgent} = (await import(
- // @ts-expect-error No types for this specific file
- `undici/lib/proxy-agent.js`
- )) as { default: typeof import('undici').ProxyAgent };
+ const {ProxyAgent} = await import(`undici`);
return new ProxyAgent(proxy);
} |
AFAICT it should not have any effect – except making the bundle size bigger. But it's certainly something we can try, we'd just need a way to reproduce the issue first so we can validate if that has any effect. |
@aduh95 I'm trying to reproduce. Is it the way to reproduce that you expected?
import {afterAll, beforeAll, describe, expect, it} from '@jest/globals';
import process from 'node:process';
import { createProxy } from 'proxy'; // Need `yarn add proxy --dev`.
import type { ProxyServer } from 'proxy';
import { fetchAsJson } from '../sources/httpUtils';
describe(`reproduce issue #444`, () => {
let proxy: ProxyServer;
beforeAll((done) => {
proxy = createProxy();
proxy.listen(done);
})
afterAll((done) => {
proxy.close(done);
})
it(`without proxy settings`, async () => {
await expect(fetchAsJson(`https://registry.npmjs.org/yarn`)).resolves.toEqual(expect.anything());
});
it(`with proxy settings`, async () => {
process.env.HTTPS_PROXY = `http://localhost:${proxy.address().port}`;
await expect(fetchAsJson(`https://registry.npmjs.org/yarn`)).resolves.toEqual(expect.anything());
// TODO: Test fails.
// Received promise rejected instead of resolved
// Rejected to value: [Error: Error when performing the request to https://registry.npmjs.org/yarn; for troubleshooting help, see https://github.com/nodejs/corepack#troubleshooting]
});
}); |
Looks like the same reason as here currently in discussion. So my issue is closed. Duplicate of #417 |
Error when downloading yarn with proxy settings.
Details with
NODE_DEBUG
are below:this[kClient].connect is not a function
error has occurred.corepack imports
undici/lib/proxy-agent.js
to useProxyAgent
, butconnect
function is not found here.https://github.com/nodejs/corepack/blob/v0.26.0/sources/httpUtils.ts#L66-L81
https://github.com/nodejs/undici/blob/v6.6.2/lib/proxy-agent.js
https://github.com/nodejs/undici/blob/v6.6.2/lib/dispatcher-base.js
https://github.com/nodejs/undici/blob/v6.6.2/lib/dispatcher.js
After searching, I found that
connect
function is assigned toDispatcher
onindex.js
.https://github.com/nodejs/undici/blob/v6.6.2/index.js#L24
https://github.com/nodejs/undici/blob/v6.6.2/lib/api/index.js
https://github.com/nodejs/undici/blob/v6.6.2/lib/api/api-connect.js
I hope the above report will help to resolve this issue.
The text was updated successfully, but these errors were encountered: