File tree Expand file tree Collapse file tree 1 file changed +18
-5
lines changed
Expand file tree Collapse file tree 1 file changed +18
-5
lines changed Original file line number Diff line number Diff line change @@ -378,15 +378,28 @@ export class RequestExecutor implements IDisposable {
378378 }
379379 }
380380
381- private static async createAgent ( options : Agent . Options ) {
381+ private static async createAgent ( options : Agent . Options ) {
382+ try {
383+ let AgentInstance ;
384+
382385 try {
383- const { Agent : AgentInstance } = await import ( importFix ( "undici" ) ) ;
384- return new AgentInstance ( options ) ;
386+ const undiciModule = await import ( importFix ( "undici" ) ) ;
387+ AgentInstance = undiciModule . Agent ;
385388 } catch ( err ) {
386- // If we can't import undici - we might be in cloudflare env - simply return no-agent.
387- return null ;
389+ const undiciModule = await import ( "undici" ) ;
390+ AgentInstance = undiciModule . Agent ;
391+ }
392+
393+ if ( ! AgentInstance ) {
394+ throw new Error ( "Agent not found in undici module" ) ;
388395 }
396+
397+ return new AgentInstance ( options ) ;
398+ } catch ( err ) {
399+ // If we can't import undici - we might be in cloudflare env - simply return no-agent.
400+ return null ;
389401 }
402+ }
390403
391404 public getTopologyNodes ( ) : ServerNode [ ] {
392405 const topology = this . getTopology ( ) ;
You can’t perform that action at this time.
0 commit comments