@@ -4,11 +4,10 @@ import net from 'node:net';
4
4
import http from 'node:http' ;
5
5
import stream from 'node:stream' ;
6
6
import { pipeline as streamPipeline } from 'node:stream/promises' ;
7
+ import { Agent } from 'node:https' ;
7
8
import test from 'ava' ;
8
9
import getStream from 'get-stream' ;
9
10
import is from '@sindresorhus/is' ;
10
- import { SocksProxyAgent } from 'socks-proxy-agent' ;
11
- import { SocksClientError } from 'socks' ;
12
11
import got , { RequestError , HTTPError , TimeoutError } from '../source/index.js' ;
13
12
import type Request from '../source/core/index.js' ;
14
13
import withServer from './helpers/with-server.js' ;
@@ -369,10 +368,17 @@ test('should wrap got cause', async t => {
369
368
} ) ;
370
369
371
370
test ( 'should wrap non-got cause' , async t => {
371
+ class SocksProxyAgent extends Agent {
372
+ createConnection ( ) {
373
+ throw new SocksClientError ( 'oh no' ) ;
374
+ }
375
+ }
376
+ class SocksClientError extends Error { }
372
377
const error = await t . throwsAsync < RequestError > ( got ( 'https://github.com' , { retry :
{ limit :
0 } , timeout :
{ read :
1 } , agent :
{ https :
new SocksProxyAgent ( 'socks://your-name%40gmail.com:[email protected] ' ) } } ) ) ;
373
378
const cause = error ?. cause as Error ;
374
379
t . is ( error ?. code , 'ERR_GOT_REQUEST_ERROR' ) ;
375
380
t . is ( error ?. message , cause . message ) ;
381
+ t . is ( error ?. message , 'oh no' ) ;
376
382
t . assert ( cause instanceof SocksClientError ) ;
377
383
} ) ;
378
384
0 commit comments