Skip to content

Commit

Permalink
fix(db): parseArguments during try block
Browse files Browse the repository at this point in the history
Error catching when unexpected data is passed to query string.
  • Loading branch information
thelindat committed Dec 28, 2021
1 parent d54bcae commit 47a33bb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/server/db/query.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import pool from './pool.js';

export default async (type, invokingResource, query, parameters, cb) => {
if (!isReady) serverReady();

[query, parameters, cb] = parseArguments(invokingResource, query, parameters, cb);
scheduleTick();
let result, executionTime;

try {
[query, parameters, cb] = parseArguments(invokingResource, query, parameters, cb);
scheduleTick();

[result, _, executionTime] = await pool.query(query, parameters);

if (executionTime >= mysql_slow_query_warning || mysql_debug)
Expand Down
3 changes: 1 addition & 2 deletions src/server/db/transaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,12 @@ const transactionError = (queries, parameters) =>

export default async (invokingResource, queries, parameters, cb) => {
if (!isReady) serverReady();

const parsedQuery = parseTransaction(invokingResource, queries, parameters);
scheduleTick();
const connection = await pool.getConnection();
let result;

try {
const parsedQuery = parseTransaction(invokingResource, queries, parameters);
let queryCount = parsedQuery.length;
let executionTime = hrtime();

Expand Down

0 comments on commit 47a33bb

Please sign in to comment.