Skip to content

Commit cace9b7

Browse files
committed
fix port issues
1 parent 1baed6e commit cace9b7

File tree

4 files changed

+22
-14
lines changed

4 files changed

+22
-14
lines changed

dev-packages/node-integration-tests/suites/tracing/anthropic/scenario.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import Anthropic from '@anthropic-ai/sdk';
22
import * as Sentry from '@sentry/node';
33
import express from 'express';
44

5-
const PORT = 3335;
5+
const PORT = 3333;
66

77
function startMockAnthropicServer() {
88
const app = express();

dev-packages/node-integration-tests/suites/tracing/google-genai/scenario-streaming.mjs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { GoogleGenAI } from '@google/genai';
22
import * as Sentry from '@sentry/node';
33
import express from 'express';
44

5-
const PORT = 3334;
65

76
function startMockGoogleGenAIServer() {
87
const app = express();
@@ -39,7 +38,11 @@ function startMockGoogleGenAIServer() {
3938
sendChunk();
4039
});
4140

42-
return app.listen(PORT);
41+
return new Promise(resolve => {
42+
app.listen(server => {
43+
resolve(server);
44+
});
45+
});
4346
}
4447

4548
// Helper function to create mock stream
@@ -133,12 +136,12 @@ async function* createMockStream(model) {
133136
}
134137

135138
async function run() {
136-
const server = startMockGoogleGenAIServer();
139+
const server = await startMockGoogleGenAIServer();
137140

138141
await Sentry.startSpan({ op: 'function', name: 'main' }, async () => {
139142
const client = new GoogleGenAI({
140143
apiKey: 'mock-api-key',
141-
httpOptions: { baseUrl: `http://localhost:${PORT}` },
144+
httpOptions: { baseUrl: `http://localhost:${server.address().port}` },
142145
});
143146

144147
// Test 1: models.generateContentStream (streaming)

dev-packages/node-integration-tests/suites/tracing/google-genai/scenario-tools.mjs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { GoogleGenAI } from '@google/genai';
22
import * as Sentry from '@sentry/node';
33
import express from 'express';
44

5-
const PORT = 3337;
65

76
function startMockGoogleGenAIServer() {
87
const app = express();
@@ -118,7 +117,11 @@ function startMockGoogleGenAIServer() {
118117
sendChunk();
119118
});
120119

121-
return app.listen(PORT);
120+
return new Promise(resolve => {
121+
app.listen(server => {
122+
resolve(server);
123+
});
124+
});
122125
}
123126

124127
// Helper function to create mock stream
@@ -221,12 +224,12 @@ async function* createMockToolsStream({ tools }) {
221224
}
222225

223226
async function run() {
224-
const server = startMockGoogleGenAIServer();
227+
const server = await startMockGoogleGenAIServer();
225228

226229
await Sentry.startSpan({ op: 'function', name: 'main' }, async () => {
227230
const client = new GoogleGenAI({
228231
apiKey: 'mock-api-key',
229-
httpOptions: { baseUrl: `http://localhost:${PORT}` },
232+
httpOptions: { baseUrl: `http://localhost:${server.address().port}` },
230233
});
231234

232235
// Test 1: Non-streaming with tools

dev-packages/node-integration-tests/suites/tracing/google-genai/scenario.mjs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ import { GoogleGenAI } from '@google/genai';
22
import * as Sentry from '@sentry/node';
33
import express from 'express';
44

5-
const PORT = 3336;
6-
75
function startMockGoogleGenAIServer() {
86
const app = express();
97
app.use(express.json());
@@ -39,16 +37,20 @@ function startMockGoogleGenAIServer() {
3937
});
4038
});
4139

42-
return app.listen(PORT);
40+
return new Promise(resolve => {
41+
app.listen(server => {
42+
resolve(server);
43+
});
44+
});
4345
}
4446

4547
async function run() {
46-
const server = startMockGoogleGenAIServer();
48+
const server = await startMockGoogleGenAIServer();
4749

4850
await Sentry.startSpan({ op: 'function', name: 'main' }, async () => {
4951
const client = new GoogleGenAI({
5052
apiKey: 'mock-api-key',
51-
httpOptions: { baseUrl: `http://localhost:${PORT}` },
53+
httpOptions: { baseUrl: `http://localhost:${server.address().port}` },
5254
});
5355

5456
// Test 1: chats.create and sendMessage flow

0 commit comments

Comments
 (0)