Skip to content

Commit 02f09e0

Browse files
authored
Merge pull request #777 from getmaxun/screenshot-fix
fix: screenshot not being displayed
2 parents b0f2c85 + 0b8fe5c commit 02f09e0

File tree

3 files changed

+37
-3
lines changed

3 files changed

+37
-3
lines changed

server/src/api/record.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -612,11 +612,22 @@ async function executeRun(id: string, userId: string) {
612612
log: interpretationInfo.log.join('\n'),
613613
});
614614

615+
// Upload binary output to MinIO and update run with MinIO URLs
616+
const finalRun = await Run.findOne({ where: { runId: id } });
617+
if (finalRun && finalRun.binaryOutput && Object.keys(finalRun.binaryOutput).length > 0) {
618+
try {
619+
const binaryService = new BinaryOutputService('maxun-run-screenshots');
620+
await binaryService.uploadAndStoreBinaryOutput(finalRun, finalRun.binaryOutput);
621+
logger.log('info', `Uploaded binary output to MinIO for API run ${id}`);
622+
} catch (minioError: any) {
623+
logger.log('error', `Failed to upload binary output to MinIO for API run ${id}: ${minioError.message}`);
624+
}
625+
}
626+
615627
let totalSchemaItemsExtracted = 0;
616628
let totalListItemsExtracted = 0;
617629
let extractedScreenshotsCount = 0;
618630

619-
const finalRun = await Run.findOne({ where: { runId: id } });
620631
if (finalRun) {
621632
if (finalRun.serializableOutput) {
622633
if (finalRun.serializableOutput.scrapeSchema) {

server/src/pgboss-worker.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import { googleSheetUpdateTasks, processGoogleSheetUpdates } from './workflow-ma
1919
import { airtableUpdateTasks, processAirtableUpdates } from './workflow-management/integrations/airtable';
2020
import { io as serverIo } from "./server";
2121
import { sendWebhook } from './routes/webhook';
22+
import { BinaryOutputService } from './storage/mino';
2223

2324
if (!process.env.DB_USER || !process.env.DB_PASSWORD || !process.env.DB_HOST || !process.env.DB_PORT || !process.env.DB_NAME) {
2425
throw new Error('Failed to start pgboss worker: one or more required environment variables are missing.');
@@ -242,11 +243,22 @@ async function processRunExecution(job: Job<ExecuteRunData>) {
242243
log: interpretationInfo.log.join('\n')
243244
});
244245

246+
// Upload binary output to MinIO and update run with MinIO URLs
247+
const updatedRun = await Run.findOne({ where: { runId: data.runId } });
248+
if (updatedRun && updatedRun.binaryOutput && Object.keys(updatedRun.binaryOutput).length > 0) {
249+
try {
250+
const binaryService = new BinaryOutputService('maxun-run-screenshots');
251+
await binaryService.uploadAndStoreBinaryOutput(updatedRun, updatedRun.binaryOutput);
252+
logger.log('info', `Uploaded binary output to MinIO for run ${data.runId}`);
253+
} catch (minioError: any) {
254+
logger.log('error', `Failed to upload binary output to MinIO for run ${data.runId}: ${minioError.message}`);
255+
}
256+
}
257+
245258
let totalSchemaItemsExtracted = 0;
246259
let totalListItemsExtracted = 0;
247260
let extractedScreenshotsCount = 0;
248261

249-
const updatedRun = await Run.findOne({ where: { runId: data.runId } });
250262
if (updatedRun) {
251263
if (updatedRun.serializableOutput) {
252264
if (updatedRun.serializableOutput.scrapeSchema) {

server/src/workflow-management/scheduler/index.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,12 +176,23 @@ async function executeRun(id: string, userId: string) {
176176
log: interpretationInfo.log.join('\n'),
177177
});
178178

179+
// Upload binary output to MinIO and update run with MinIO URLs
180+
const updatedRun = await Run.findOne({ where: { runId: id } });
181+
if (updatedRun && updatedRun.binaryOutput && Object.keys(updatedRun.binaryOutput).length > 0) {
182+
try {
183+
const binaryService = new BinaryOutputService('maxun-run-screenshots');
184+
await binaryService.uploadAndStoreBinaryOutput(updatedRun, updatedRun.binaryOutput);
185+
logger.log('info', `Uploaded binary output to MinIO for scheduled run ${id}`);
186+
} catch (minioError: any) {
187+
logger.log('error', `Failed to upload binary output to MinIO for scheduled run ${id}: ${minioError.message}`);
188+
}
189+
}
190+
179191
// Get metrics from persisted data for analytics and webhooks
180192
let totalSchemaItemsExtracted = 0;
181193
let totalListItemsExtracted = 0;
182194
let extractedScreenshotsCount = 0;
183195

184-
const updatedRun = await Run.findOne({ where: { runId: id } });
185196
if (updatedRun) {
186197
if (updatedRun.serializableOutput) {
187198
if (updatedRun.serializableOutput.scrapeSchema) {

0 commit comments

Comments
 (0)