Skip to content

Commit 423e2f6

Browse files
authored
Merge pull request #482 from M4xymm/RDBC-908
RDBC-908 Node.js Client malfunction in ssr applications
2 parents d7bd8b3 + db517b2 commit 423e2f6

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

src/Http/RequestExecutor.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff 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;

0 commit comments

Comments
 (0)