Reputation: 310
I am planning to deploy an Angular website with node.js backend and mySQL database to a shared hosting that support it. The hosting website has a limit of maximum 25 concurrent connections to mySQL database at a time.
I am using mySQL module in node.js to access the database. Here is a pseudo-code that represents the structure:
const mysql = require('mysql');
app.get('/query/:id', function (req, res) {
let mc = mysql.createConnection(...);
mc.connect((err)=>{
...
mc.query(...);}
);});
Now what I am not sure about is: If the maximum concurrent connection limit to the database is reached, where will the error generate? Will the error come from this step:
mysql.createConnection()
, or this step:
mc.connect()
,or this step:
mc.query()
Also, where is the most appropriate place to deal with the error?
Upvotes: 0
Views: 49
Reputation: 606
Based on the documentation for error handling: https://github.com/mysqljs/mysql#error-handling
You would see an error in both the mc.connect()
and mc.query
callbacks, however in your case above it probably wouldn't make it to the mc.query
since that is inside of the mc.connect
callback.
Upvotes: 1