Skip to content

Commit 943a672

Browse files
authored
Merge pull request #71 from evalstate/fix/small-updates
increase batch size for logging, improve shutdown handling and gradio endpoint warnings
2 parents 88449e8 + f3d436e commit 943a672

File tree

7 files changed

+37
-20
lines changed

7 files changed

+37
-20
lines changed

packages/app/src/server/gradio-endpoint-connector.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -187,15 +187,6 @@ async function fetchEndpointSchema(
187187
clearTimeout(timeoutId);
188188

189189
if (!response.ok) {
190-
logger.error(
191-
{
192-
endpointId,
193-
subdomain: endpoint.subdomain,
194-
status: response.status,
195-
statusText: response.statusText,
196-
},
197-
'Failed to fetch schema from endpoint'
198-
);
199190
throw new Error(`Failed to fetch schema: ${response.status} ${response.statusText}`);
200191
}
201192

packages/app/src/server/sse.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,13 @@ async function start() {
3535
await app.start();
3636

3737
// Handle server shutdown
38+
let shutdownInProgress = false;
3839
const shutdown = async () => {
3940
logger.info('Shutting down server...');
41+
shutdownInProgress = true;
4042
try {
4143
await app.stop();
4244
logger.info('Server shutdown complete');
43-
process.exit(0);
4445
} catch (error) {
4546
logger.error({ error }, 'Error during shutdown');
4647
process.exit(1);
@@ -49,6 +50,13 @@ async function start() {
4950

5051
process.once('SIGINT', () => {
5152
void shutdown();
53+
// Set up second SIGINT handler for force exit
54+
process.once('SIGINT', () => {
55+
if (shutdownInProgress) {
56+
logger.warn('Force exit requested, terminating immediately...');
57+
process.exit(1);
58+
}
59+
});
5260
});
5361

5462
process.once('SIGTERM', () => {

packages/app/src/server/stdio.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,13 @@ async function main() {
4040
await app.start();
4141

4242
// Handle server shutdown
43+
let shutdownInProgress = false;
4344
const shutdown = async () => {
4445
logger.info('Shutting down server...');
46+
shutdownInProgress = true;
4547
try {
4648
await app.stop();
4749
logger.info('Server shutdown complete');
48-
process.exit(0);
4950
} catch (error) {
5051
logger.error({ error }, 'Error during shutdown');
5152
process.exit(1);
@@ -54,6 +55,13 @@ async function main() {
5455

5556
process.once('SIGINT', () => {
5657
void shutdown();
58+
// Set up second SIGINT handler for force exit
59+
process.once('SIGINT', () => {
60+
if (shutdownInProgress) {
61+
logger.warn('Force exit requested, terminating immediately...');
62+
process.exit(1);
63+
}
64+
});
5765
});
5866

5967
process.once('SIGTERM', () => {

packages/app/src/server/streamableHttp.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,13 @@ async function start() {
4646
await app.start();
4747

4848
// Handle server shutdown
49+
let shutdownInProgress = false;
4950
const shutdown = async () => {
5051
logger.info('Shutting down server...');
52+
shutdownInProgress = true;
5153
try {
5254
await app.stop();
5355
logger.info('Server shutdown complete');
54-
process.exit(0);
5556
} catch (error) {
5657
logger.error({ error }, 'Error during shutdown');
5758
process.exit(1);
@@ -60,6 +61,13 @@ async function start() {
6061

6162
process.once('SIGINT', () => {
6263
void shutdown();
64+
// Set up second SIGINT handler for force exit
65+
process.once('SIGINT', () => {
66+
if (shutdownInProgress) {
67+
logger.warn('Force exit requested, terminating immediately...');
68+
process.exit(1);
69+
}
70+
});
6371
});
6472

6573
process.once('SIGTERM', () => {

packages/app/src/server/utils/hf-dataset-transport.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export class HfDatasetLogger {
3838
private uploadInProgress = false;
3939
private sessionId: string;
4040
private uploadFunction: typeof UploadFileFunction;
41-
private readonly maxBufferSize: number = 1000;
41+
private readonly maxBufferSize: number = 10000;
4242
private logType: string;
4343

4444
constructor(options: HfDatasetTransportOptions) {

packages/app/src/shared/settings.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,14 @@ export const DEFAULT_SPACE_TOOLS: SpaceTool[] = [
2626
subdomain: 'evalstate-flux1-schnell',
2727
emoji: '🏎️💨',
2828
},
29+
/*
2930
{
3031
_id: '680be03dc38b7fa7d6855910',
3132
name: 'abidlabs/EasyGhibli',
3233
subdomain: 'abidlabs-easyghibli',
3334
emoji: '🦀',
3435
},
36+
*/
3537
];
3638

3739
// Default settings

packages/app/test/server/utils/hf-dataset-transport.test.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,10 @@ describe('HfDatasetLogger', () => {
8888
});
8989

9090
it('should drop oldest logs when buffer exceeds maximum size', async () => {
91-
logger = createTestLogger({ batchSize: 2000, flushInterval: 60000 }); // Prevent auto-flush
91+
logger = createTestLogger({ batchSize: 20000, flushInterval: 60000 }); // Prevent auto-flush
9292

93-
// Add logs to exceed buffer capacity (maxBufferSize = 1000)
94-
for (let i = 0; i < 1002; i++) {
93+
// Add logs to exceed buffer capacity (maxBufferSize = 10000)
94+
for (let i = 0; i < 10002; i++) {
9595
logger.processLog({
9696
level: 30,
9797
time: Date.now(),
@@ -102,8 +102,8 @@ describe('HfDatasetLogger', () => {
102102
// Wait a bit to ensure all logs are processed
103103
await new Promise((resolve) => setTimeout(resolve, 10));
104104

105-
// Buffer should be at max size (1000), not 1002
106-
expect(logger.getStatus().bufferSize).toBe(1000);
105+
// Buffer should be at max size (10000), not 10002
106+
expect(logger.getStatus().bufferSize).toBe(10000);
107107
});
108108
});
109109

@@ -254,7 +254,7 @@ describe('HfDatasetLogger', () => {
254254

255255
const status = logger.getStatus();
256256
expect(status).toBeDefined();
257-
expect(status.bufferSize).toBeLessThanOrEqual(1000); // Should respect max buffer size
257+
expect(status.bufferSize).toBeLessThanOrEqual(10000); // Should respect max buffer size
258258
});
259259
});
260260

@@ -322,7 +322,7 @@ describe('HfDatasetLogger', () => {
322322

323323
const status = logger.getStatus();
324324
// Should not accumulate unlimited logs
325-
expect(status.bufferSize).toBeLessThanOrEqual(1000);
325+
expect(status.bufferSize).toBeLessThanOrEqual(10000);
326326
});
327327

328328
it('should handle large log messages efficiently', () => {

0 commit comments

Comments
 (0)