File tree Expand file tree Collapse file tree 1 file changed +15
-2
lines changed
Expand file tree Collapse file tree 1 file changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -380,8 +380,21 @@ export class RequestExecutor implements IDisposable {
380380
381381 private static async createAgent ( options : Agent . Options ) {
382382 try {
383- const { Agent : AgentInstance } = await import ( importFix ( "undici" ) ) ;
384- return new AgentInstance ( options ) ;
383+ let UndiciAgent ;
384+
385+ try {
386+ const undiciModule = await import ( importFix ( "undici" ) ) ;
387+ UndiciAgent = undiciModule . Agent ;
388+ } catch ( err ) {
389+ const undiciModule = await import ( "undici" ) ;
390+ UndiciAgent = undiciModule . Agent ;
391+ }
392+
393+ if ( ! UndiciAgent ) {
394+ throw new Error ( "Agent not found in undici module" ) ;
395+ }
396+
397+ return new UndiciAgent ( options ) ;
385398 } catch ( err ) {
386399 // If we can't import undici - we might be in cloudflare env - simply return no-agent.
387400 return null ;
You can’t perform that action at this time.
0 commit comments