-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(devtools-proxy-agent): properly forward errors for Socks5 requests (
#457)
- Loading branch information
Showing
2 changed files
with
50 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -208,6 +208,33 @@ describe('createSocks5Tunnel', function () { | |
expect(await response.text()).to.equal('OK /hello'); | ||
}); | ||
|
||
it('properly handles forwarding failures', async function () { | ||
tunnel = await setupSocks5Tunnel( | ||
{ | ||
useEnvironmentVariableProxies: true, | ||
env: { | ||
MONGODB_PROXY: `http://foo:[email protected]:1`, | ||
}, | ||
}, | ||
{}, | ||
'mongodb://' | ||
); | ||
if (!tunnel) { | ||
// regular conditional instead of assertion so that TS can follow it | ||
expect.fail('failed to create Socks5 tunnel'); | ||
} | ||
|
||
try { | ||
const fetch = createFetch({ | ||
proxy: `socks5://@127.0.0.1:${tunnel.config.proxyPort}`, | ||
}); | ||
await fetch('http://example.com/hello'); | ||
expect.fail('missed exception'); | ||
} catch (err: any) { | ||
expect(err.message).to.include('Socket closed'); | ||
} | ||
}); | ||
|
||
context('with a non-HTTP target', function () { | ||
let netServer: Server; | ||
beforeEach(async function () { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters