Skip to content
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

fix: TypeError: SocksProxyAgent is not a constructor #161

Merged
merged 3 commits into from
Jun 20, 2022

Conversation

Janlaywss
Copy link
Contributor

@Janlaywss Janlaywss commented Jun 17, 2022

What

Bug: SocksProxyAgent is not a constructor

In the documentation and code of socks-proxy-agent 7.0.0, the SocksProxyAgent class is no longer exported by default.
image

So when we use the default export, the error SocksProxyAgent is not a constructor will be thrown
image

@Janlaywss Janlaywss requested a review from a team as a code owner June 17, 2022 10:30
lib/agent.js Outdated Show resolved Hide resolved
Copy link
Member

@wraithgar wraithgar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fixing this @Janlaywss

@wraithgar wraithgar self-requested a review June 18, 2022 16:57
@wraithgar
Copy link
Member

I forgot about tests when I clicked approve. This should fix things. You'll also need to npm run lintfix.

diff --git a/test/agent.js b/test/agent.js
index 0b721d7..f8def79 100644
--- a/test/agent.js
+++ b/test/agent.js
@@ -9,7 +9,7 @@ const agent = t.mock('../lib/agent.js', {
   agentkeepalive: MockHttp,
   'https-proxy-agent': mockHttpAgent('https-proxy'),
   'http-proxy-agent': mockHttpAgent('http-proxy'),
-  'socks-proxy-agent': mockHttpAgent('socks-proxy'),
+  'socks-proxy-agent': { SocksProxyAgent: mockHttpAgent('socks-proxy') },
 })

@Janlaywss
Copy link
Contributor Author

I forgot about tests when I clicked approve. This should fix things. You'll also need to npm run lintfix.

diff --git a/test/agent.js b/test/agent.js

index 0b721d7..f8def79 100644

--- a/test/agent.js

+++ b/test/agent.js

@@ -9,7 +9,7 @@ const agent = t.mock('../lib/agent.js', {

   agentkeepalive: MockHttp,

   'https-proxy-agent': mockHttpAgent('https-proxy'),

   'http-proxy-agent': mockHttpAgent('http-proxy'),

-  'socks-proxy-agent': mockHttpAgent('socks-proxy'),

+  'socks-proxy-agent': { SocksProxyAgent: mockHttpAgent('socks-proxy') },

 })

Ok, thanks a lot. I'll fix it

@Janlaywss
Copy link
Contributor Author

I forgot about tests when I clicked approve. This should fix things. You'll also need to npm run lintfix.

diff --git a/test/agent.js b/test/agent.js
index 0b721d7..f8def79 100644
--- a/test/agent.js
+++ b/test/agent.js
@@ -9,7 +9,7 @@ const agent = t.mock('../lib/agent.js', {
   agentkeepalive: MockHttp,
   'https-proxy-agent': mockHttpAgent('https-proxy'),
   'http-proxy-agent': mockHttpAgent('http-proxy'),
-  'socks-proxy-agent': mockHttpAgent('socks-proxy'),
+  'socks-proxy-agent': { SocksProxyAgent: mockHttpAgent('socks-proxy') },
 })

The test case has been modified. After modification, my local npm run lintfix all passed.

lib/agent.js Outdated Show resolved Hide resolved
@wraithgar wraithgar merged commit 4ae4864 into npm:main Jun 20, 2022
@wraithgar
Copy link
Member

Thanks, this should go out w/ the next npm cli release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants