Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ workflows:
- feature/top-262-projectid-non-mandatory
- TOP-2364
- PM-2097
- pm-2456
- pm-2539

- "build-qa":
context: org-global
Expand Down
1 change: 1 addition & 0 deletions config/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,4 +129,5 @@ module.exports = {
// Database schemas for direct counts (shared DB)
RESOURCES_DB_SCHEMA: process.env.RESOURCES_DB_SCHEMA || "resources",
REVIEW_DB_SCHEMA: process.env.REVIEW_DB_SCHEMA || "reviews",
CHALLENGE_SERVICE_PRISMA_TIMEOUT: process.env.CHALLENGE_SERVICE_PRISMA_TIMEOUT ? parseInt(process.env.CHALLENGE_SERVICE_PRISMA_TIMEOUT, 10) : 10000,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[💡 correctness]
Using parseInt without specifying the radix can lead to unexpected results if the environment variable CHALLENGE_SERVICE_PRISMA_TIMEOUT starts with '0'. It's good practice to always specify the radix, which is correctly done here with 10. Ensure this pattern is consistently applied throughout the codebase.

};
6 changes: 5 additions & 1 deletion src/common/prisma.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,12 @@ const {
ReviewOpportunityTypeEnum,
} = require("@prisma/client");
const logger = require("./logger");
const config = require("config");

const prismaClient = new PrismaClient({
transactionOptions: {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[❗❗ correctness]
The transactionOptions object is defined twice in the PrismaClient constructor. This could lead to unexpected behavior as the second definition will override the first. Consider merging these options into a single transactionOptions object to ensure clarity and prevent potential configuration issues.

timeout: config.CHALLENGE_SERVICE_PRISMA_TIMEOUT,
},
log: [
{ level: "query", emit: "event" },
{ level: "info", emit: "event" },
Expand All @@ -21,7 +25,7 @@ const prismaClient = new PrismaClient({
// Allow overriding via environment variables if needed.
transactionOptions: {
maxWait: Number(process.env.PRISMA_TRANSACTION_MAX_WAIT_MS || 10000), // wait up to 10s to start
timeout: Number(process.env.PRISMA_TRANSACTION_TIMEOUT_MS || 10000), // allow up to 30s per transaction
timeout: config.CHALLENGE_SERVICE_PRISMA_TIMEOUT, // allow up to 30s per transaction
},
});

Expand Down
2 changes: 1 addition & 1 deletion src/common/review-prisma.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const createClient = () =>
],
transactionOptions: {
maxWait: Number(process.env.PRISMA_TRANSACTION_MAX_WAIT_MS || 10000),
timeout: Number(process.env.PRISMA_TRANSACTION_TIMEOUT_MS || 10000),
timeout: config.CHALLENGE_SERVICE_PRISMA_TIMEOUT,
},
});

Expand Down