Skip to content

Commit f0d836f

Browse files
committed
Add more logging around new metadata system
1 parent d52e3d7 commit f0d836f

File tree

2 files changed

+34
-22
lines changed

2 files changed

+34
-22
lines changed

apps/webapp/app/services/metadata/updateMetadata.server.ts

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,15 @@ export class UpdateMetadataService extends BaseService {
351351
});
352352

353353
if (result.count === 0) {
354+
if (this.flushLoggingEnabled) {
355+
logger.debug(
356+
`[UpdateMetadataService][updateRunMetadataWithOperations] Optimistic lock failed for run ${runId}`,
357+
{
358+
metadataVersion: run.metadataVersion,
359+
}
360+
);
361+
}
362+
354363
// If this was our last attempt, buffer the operations and return optimistically
355364
if (attempts === MAX_RETRIES) {
356365
this.#ingestRunOperations(runId, operations);
@@ -363,6 +372,15 @@ export class UpdateMetadataService extends BaseService {
363372
continue;
364373
}
365374

375+
if (this.flushLoggingEnabled) {
376+
logger.debug(
377+
`[UpdateMetadataService][updateRunMetadataWithOperations] Updated metadata for run ${runId}`,
378+
{
379+
metadata: applyResults.newMetadata,
380+
}
381+
);
382+
}
383+
366384
// Success! Return the new metadata
367385
return applyResults.newMetadata;
368386
}
@@ -383,10 +401,15 @@ export class UpdateMetadataService extends BaseService {
383401
metadataPacket.data !== "{}" ||
384402
(existingMetadata.data && metadataPacket.data !== existingMetadata.data)
385403
) {
386-
logger.debug(`Updating metadata directly for run`, {
387-
metadata: metadataPacket.data,
388-
runId,
389-
});
404+
if (this.flushLoggingEnabled) {
405+
logger.debug(
406+
`[UpdateMetadataService][updateRunMetadataDirectly] Updating metadata directly for run`,
407+
{
408+
metadata: metadataPacket.data,
409+
runId,
410+
}
411+
);
412+
}
390413

391414
// Update the metadata without version check
392415
await this._prisma.taskRun.update({
@@ -416,6 +439,13 @@ export class UpdateMetadataService extends BaseService {
416439
};
417440
});
418441

442+
if (this.flushLoggingEnabled) {
443+
logger.debug(`[UpdateMetadataService] Ingesting operations for run`, {
444+
runId,
445+
bufferedOperations,
446+
});
447+
}
448+
419449
const existingBufferedOperations = this._bufferedOperations.get(runId) ?? [];
420450

421451
this._bufferedOperations.set(runId, [...existingBufferedOperations, ...bufferedOperations]);

references/nextjs-realtime/src/trigger/csv.ts

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -62,16 +62,6 @@ export const handleCSVUpload = schemaTask({
6262
const successfulRows = results.runs.filter((r) => r.ok);
6363
const failedRows = results.runs.filter((r) => !r.ok);
6464

65-
const firstSuccessfulRow = successfulRows[0];
66-
67-
if (firstSuccessfulRow) {
68-
const stream = await metadata.fetchStream<string>(firstSuccessfulRow.id);
69-
70-
for await (const value of stream) {
71-
logger.info(`Stream value from ${firstSuccessfulRow.id}`, { value });
72-
}
73-
}
74-
7565
return {
7666
file,
7767
rows,
@@ -93,14 +83,6 @@ export const handleCSVRow = schemaTask({
9383

9484
metadata.parent.increment("processedRows", 1).append("rowRuns", ctx.run.id);
9585

96-
await metadata.parent.stream(
97-
ctx.run.id,
98-
(async function* () {
99-
yield "hello";
100-
yield "world";
101-
})()
102-
);
103-
10486
return row;
10587
},
10688
});

0 commit comments

Comments
 (0)