From a5ab7dcf3b5b56463fe6f4aca3ad5d8b1960d4cd Mon Sep 17 00:00:00 2001 From: Kevin Chung Date: Wed, 25 Jun 2025 00:16:55 -0400 Subject: [PATCH 1/5] Bump playwright version --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index fbdde15..1d1a94c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,7 +3,7 @@ WORKDIR /build COPY . . RUN yarn && yarn build -FROM mcr.microsoft.com/playwright:v1.31.1-focal +FROM mcr.microsoft.com/playwright:v1.53.1-jammy LABEL org.opencontainers.image.source="https://github.com/CTFd/Tourist" RUN apt update && \ From ed627ad5e1ce8c4d24f9abd7945842ef4b72239f Mon Sep 17 00:00:00 2001 From: Kevin Chung Date: Wed, 25 Jun 2025 00:24:05 -0400 Subject: [PATCH 2/5] Bump node-version --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4da0ff5..ecba8ee 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -26,7 +26,7 @@ jobs: strategy: matrix: - node-version: [16.x, 18.x] + node-version: [20.x, 22.x] steps: - uses: actions/checkout@v3 From 930cd48c75ef3c6c965030a79c2065b200c4ca57 Mon Sep 17 00:00:00 2001 From: Kevin Chung Date: Wed, 25 Jun 2025 15:07:17 -0400 Subject: [PATCH 3/5] Some logging improvements --- package.json | 2 +- src/jobs/api.ts | 6 +++++- src/routes/api.ts | 1 + src/utils/runner.ts | 4 ++-- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 7113a55..666d006 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "cmd:get-issuer-token": "ts-node ./src/cli.ts get-issuer-token", "cmd:get-visit-token": "ts-node ./src/cli.ts get-visit-token", "build": "rm -rf ./out && tsc -p tsconfig.production.json", - "start:docker": "node ./src/index.js | pino-pretty", + "start:docker": "node ./src/index.js", "start:serve": "node ./out/index.js | pino-pretty", "start:build": "yarn build && yarn start:serve", "start:dev": "nodemon ./src/index.ts | pino-pretty", diff --git a/src/jobs/api.ts b/src/jobs/api.ts index 1f4cdeb..fabaea9 100644 --- a/src/jobs/api.ts +++ b/src/jobs/api.ts @@ -22,7 +22,9 @@ export type VisitJobData = { }; export const asyncVisitJob = async (job: Job) => { + console.log(`job ${job.id} starting`) const data = job.data; + console.log(job.data) const runner = new PlaywrightRunner(data, config.DEBUG); try { @@ -37,13 +39,15 @@ export const asyncVisitJob = async (job: Job) => { // change the job status to failed with the error message await job.moveToFailed({ message: e.message }); + console.log(`job ${job.id} failed`) } - + console.log(`job ${job.id} succeeded`) return await runner.finish(); }; export const syncVisitJob = async (data: VisitJobData) => { const runner = new PlaywrightRunner(data, config.DEBUG); + console.log(data) try { await runner.init(); diff --git a/src/routes/api.ts b/src/routes/api.ts index 8b6d74f..feef33f 100644 --- a/src/routes/api.ts +++ b/src/routes/api.ts @@ -168,6 +168,7 @@ const getAsyncJobHandler = (fastify: FastifyInstance) => { } const job = await AsyncVisitQueue.add(data); + console.log(`job ${job.id} scheduled`); return reply.send({ status: "scheduled", id: job.id }); }; }; diff --git a/src/utils/runner.ts b/src/utils/runner.ts index 3083cff..d937096 100644 --- a/src/utils/runner.ts +++ b/src/utils/runner.ts @@ -89,8 +89,8 @@ export class PlaywrightRunner { } this.page = await this.context.newPage(); - this.page.setDefaultNavigationTimeout(4000); - this.page.setDefaultTimeout(2000); + this.page.setDefaultNavigationTimeout(3000); + this.page.setDefaultTimeout(1000); } // exec() iterates over steps, splits actions into pre- and post-open and executes From 53a503db13aa75c9cae459ae670b5889ba583489 Mon Sep 17 00:00:00 2001 From: Kevin Chung Date: Wed, 25 Jun 2025 15:09:07 -0400 Subject: [PATCH 4/5] Run formatter --- src/jobs/api.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/jobs/api.ts b/src/jobs/api.ts index fabaea9..ce6b959 100644 --- a/src/jobs/api.ts +++ b/src/jobs/api.ts @@ -22,9 +22,9 @@ export type VisitJobData = { }; export const asyncVisitJob = async (job: Job) => { - console.log(`job ${job.id} starting`) + console.log(`job ${job.id} starting`); const data = job.data; - console.log(job.data) + console.log(job.data); const runner = new PlaywrightRunner(data, config.DEBUG); try { @@ -39,15 +39,15 @@ export const asyncVisitJob = async (job: Job) => { // change the job status to failed with the error message await job.moveToFailed({ message: e.message }); - console.log(`job ${job.id} failed`) + console.log(`job ${job.id} failed`); } - console.log(`job ${job.id} succeeded`) + console.log(`job ${job.id} succeeded`); return await runner.finish(); }; export const syncVisitJob = async (data: VisitJobData) => { const runner = new PlaywrightRunner(data, config.DEBUG); - console.log(data) + console.log(data); try { await runner.init(); From 0ae160a2c1f266796aa9d03b4c66014c76e60467 Mon Sep 17 00:00:00 2001 From: Kevin Chung Date: Wed, 25 Jun 2025 15:29:40 -0400 Subject: [PATCH 5/5] Loosen healthcheck requirements --- src/routes/healthcheck.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/routes/healthcheck.ts b/src/routes/healthcheck.ts index eda9606..ab947d7 100644 --- a/src/routes/healthcheck.ts +++ b/src/routes/healthcheck.ts @@ -47,10 +47,10 @@ const handleHealthcheck = async (request: FastifyRequest, reply: FastifyReply) = const { screenshot } = await syncVisitJob(data); if (screenshot) { - // +/- 10% difference accepted as screenshots will differ slightly + // +/- 20% difference accepted as screenshots will differ slightly if ( - Math.floor(0.9 * EXPECTED_SCREENSHOT_LENGTH) < screenshot.length && - Math.ceil(1.1 * EXPECTED_SCREENSHOT_LENGTH) > screenshot.length + Math.floor(0.8 * EXPECTED_SCREENSHOT_LENGTH) < screenshot.length && + Math.ceil(1.2 * EXPECTED_SCREENSHOT_LENGTH) > screenshot.length ) return reply.send({ status: "OK" }); }