remove more logging

This commit is contained in:
Steven T. Cramer 2025-06-13 15:46:24 +07:00
parent 341d6a86cb
commit 13c02b6e59

View file

@ -10,29 +10,16 @@ export const dynamic = "force-dynamic"
export async function GET(request: NextRequest, { params }: { params: Promise<{ id: string }> }) {
const { id } = await params
console.log("YO YO YO - Accessing SSE stream route for run ID:", id);
const requestId = crypto.randomUUID()
console.log("YO YO YO - Processing request for run ID:", id, "with request ID:", requestId);
const stream = new SSEStream()
console.log(`YO YO YO - [stream#${requestId}] Initializing stream for run ID: ${id}`);
let run;
try {
console.log(`YO YO YO - [stream#${requestId}] Attempting to find run with ID: ${id}`);
run = await findRun(Number(id))
console.log(`YO YO YO - [stream#${requestId}] Found run with ID: ${id}`);
if (!run) {
console.error(`YO YO YO - [stream#${requestId}] Run ${id} not found`);
return new Response(`Run ${id} not found`, { status: 404 })
}
console.log(`YO YO YO - [stream#${requestId}] Successfully retrieved run data for ID: ${id}`);
} catch (error) {
console.error(`YO YO YO - [stream#${requestId}] Error finding run with ID ${id}:`, error);
return new Response("Internal server error", { status: 500 })
}
const run = await findRun(Number(id))
if (!run) {
return new Response(`Run ${id} not found`, { status: 404 })
}
const redis = await redisClient()
if (!redis) {
console.error(`YO YO YO - [stream#${requestId}] Redis client not available`);
console.error(`[stream#${requestId}] Redis client not available`);
return new Response("Internal server error", { status: 500 })
}
@ -40,7 +27,6 @@ export async function GET(request: NextRequest, { params }: { params: Promise<{
const channelName = `evals:${run.id}`
const onMessage = async (data: string) => {
console.log(`YO YO YO - [stream#${requestId}] Received message on channel ${channelName}:`, data);
if (isStreamClosed || stream.isClosed) {
return
}
@ -48,15 +34,15 @@ export async function GET(request: NextRequest, { params }: { params: Promise<{
try {
const parsedData = JSON.parse(data)
const taskEvent = taskEventSchema.parse(parsedData)
console.log(`Yo Yo Yo - [stream#${requestId}] task event -> ${taskEvent.eventName}`)
console.log(`[stream#${requestId}] task event -> ${taskEvent.eventName}`)
const writeSuccess = await stream.write(JSON.stringify(taskEvent))
if (!writeSuccess) {
console.error(`YO YO YO - [stream#${requestId}] failed to write to stream, disconnecting`);
console.error(`[stream#${requestId}] failed to write to stream, disconnecting`);
await disconnect()
}
} catch (error) {
console.error(`YO YO YO - [stream#${requestId}] invalid task event:`, data, 'Error:', error);
console.error(`[stream#${requestId}] invalid task event:`, data, 'Error:', error);
}
}
@ -78,15 +64,14 @@ export async function GET(request: NextRequest, { params }: { params: Promise<{
try {
await stream.close()
} catch (error) {
console.error(`YO YO YO - [stream#${requestId}] error closing stream:`, error);
console.error(`Error closing stream:`, error);
}
}
try {
console.log(`YO YO YO - [stream#${requestId}] subscribing to Redis channel ${channelName}`);
await redis.subscribe(channelName, onMessage)
} catch (error) {
console.error(`YO YO YO - [stream#${requestId}] error subscribing to Redis:`, error);
console.error(`Error subscribing to Redis:`, error);
return new Response("Internal server error", { status: 500 })
}