Development environment: nodejs
Library: oracle-db
Oracle Version : 9i
The test and error occurrence codes are as follows:
const oracledb = require("oracledb");
async function hello() {
await oracledb.createPool({
user: "test",
password: "1234", // myhrpw contains the hr schema password
connectString: "127.0.0.1/ORCL",
poolAlias: "ora1",
poolIncrement: 0,
poolMax: 4,
poolMin: 4,
poolPingInterval: 30,
});
const connection = await oracledb.getConnection("ora1");
const result = await connection.execute(`SELECT IDX FROM MYTABLE WHERE number= '000000000'`);
console.log(result.rows);
connection.release();
}
hello();
The database pool was created with this code. And after the test, four sessions were created and confirmed to work well. However, an error occurred due to repeated execution of the code. If only three or fewer sessions are created when creating the pool, the following error occurs:
(node:27732) UnhandledPromiseRejectionWarning: Error: ORA-12170: TNS:Connect timeout occurred
(node:27732) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:27732) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
In order to check what kind of error has occurred, I have tailed the file below.
#tail -f /oracle/app/oracle/admin/orcl/bdump/alert_orcl.log
#tail -f /oracle/app/oracle/product/9i/rdbms/log/alert_orcl.log
However, no logs were stacked and no errors were seen. Could you possibly help me?
Related
I am using Neo4j for the first time with nodejs and developing an application. I am getting the following error. I tried my best. Can you please help me with this error?
Error
(node:16148) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'get' of
undefined
at E:\fyps\app.js:120:33
at processTicksAndRejections (internal/process/task_queues.js:93:5)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:16148) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error
originated either by throwing inside of an async function without a catch block, or by
rejecting a promise which was not handled with .catch(). To terminate the node process
on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see
https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:16148) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated.
In the future, promise rejections that are not handled will terminate the Node.js
process with
a non-zero exit code.
code
app.get('/person/:id',function(req,res){
var id = req.params.id;
session
.run("MATCH (a:Person) WHERE id(a)=$idParam RETURN a.name as name", {idParam: id})
.then(function(result){
var name =result.records[0].get("name");
session
.run("OPTIONAL MATCH (a:Person)- [r:BORN_in]-(b:location) where id(a)=$idParam RETURN b.city as city, b.state as state" , {idParam:id})
.then(function(result2){
var city =result2.records[0].get("city");
var state =result2.records[0].get("state");
session
.run("OPTIONAL MATCH (a:Person)-[r:FRIENDS]-(b:Person) WHERE id(a)=$idParam RETURN b", {idParam:id})
.then(function(result3){
var friendsArr =[];
result3.records.forEach(function(record){
if(record._fields[0] != null){
friendsArr.push({
id: record._fields[0].identity.low,
name: record._fields[0].properties.name
});
}
})
res.render('person',{
id:id,
name:name,
city:city,
state:state,
friends:friendsArr
})
session.close();
})
.catch(function(error){
console.log(error);
})
can you please help me that how to solve this error.. Thanks
The error message clearly says that you are calling the get function on some entity that is undefined, and that has happened within a Promise. So, the error statement can be any one of these:
var name =result.records[0].get("name");
var city =result2.records[0].get("city");
var state =result2.records[0].get("state");
Add some relevant log statements to check which one is causing the issue.
(Welcome command using canvas)
How could I fetch the server member count as soon as someone joins??
Because I use that line of code
const guild = client.guilds.cache.get("843190900930510869");
let image = await welcomeCanvas
.setUsername(member.user.tag)
.setDiscriminator(member.user.discriminator)
.setMemberCount(guild.memberCount) //this line
etc...
And well, it just doesn't send the image..
Error:
(node:6387) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'memberCount' of undefined
at GuildMemberAddListener.exec (/app/listeners/guildMemberAdd.js:100:29)
(node:6387) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:6387) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
The event client.on('guildMemberAdd', () => {}) will return a GuildMember object. Simply use this GuildMember object to get the guild they entered GuildMember.guild then check if that guild is available to the client using guild.available. If it is available you can access all the properties on that guild including the guild.memberCount property.
client.on('guildMemberAdd', (member) => {
const guild = member.guild
if (!guild.available) return console.error('Uh Oh Stinky...')
const guildMemberCount = guild.memberCount
console.log(guildMemberCount)
})
I have the following code to perform a query on SQL server:
await sql.connect(process.env.DB_CSTRING)
let recordset = await sql.query(`select * FROM dbo.users WHERE (userId = ${userData.userId})
`)
if (recordset.rowsAffected[0] > 0) {
JsonResponse.success = 1
JsonResponse.agentData = recordset.recordset[0]
}
await sql.close();
So whille I was trying to call this API several times (by clicking on an angular app button constantly), I suddenly got the following error:
Server running at http://0.0.0.0:3000/ (node:8180)
UnhandledPromiseRejectionWarning: RequestError: No connection is
specified for that request.
I fixed it with a try-catch as per the error message below, but even if the problem is fixed, I would like to learn why this is happening and if I am doing something wrong with the way Im performing the SQL connection and query:
UnhandledPromiseRejectionWarning: Unhandled promise rejection. This
error originated either by throwing inside of an async function
without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled
promise rejection, use the CLI flag --unhandled-rejections=strict
(see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode).
(rejection id: 9)
Thanks.
Awaiting or .thening the pool creation is a safe way to ensure that the pool is always ready, without knowing where it is needed first. In practice, once the pool is created then there will be no delay for the next operation.
new sql.ConnectionPool(process.env.DB_CSTRING).connect().then(pool => {
return pool.query`select * FROM dbo.users WHERE (userId = ${userData.userId} `
}).then(result => {
console.dir(result)
}).catch(err => {
// ... error checks
})
All values are automatically sanitized against sql injection.
Source:
https://github.com/tediousjs/node-mssql#connection-pools
I was trying to load a TensorFlow fronzen model from a url that points to not existing resource to test my code robustness. However, even though I have set a catch, I am not able to manage a ECONNREFUSED that is raised internally by the function tf.loadFrozenModel.
Is there any possible mitigation to this issue? This is for me a critical problem, since it stops the execution of nodejs.
Here is the code where the error is generated.
global.fetch = require("node-fetch");
const tf = require("#tensorflow/tfjs");
require("#tensorflow/tfjs-node");
class TFModel {
...
loadFzModel(modelUrl, modelWeigths) {
return tf.loadFrozenModel(modelUrl, modelWeigths)
.then((mod) => {
this.arch = mod;
})
.catch((err) => {
console.log("Error downloading the model!");
});
}
...
}
Here instead are the errors I am getting:
UnhandledPromiseRejectionWarning: Error: http://localhost:30000/webModel/tensorflowjs_model.pb not found. FetchError: request to http://localhost:30000/webModel/tensorflowjs_model.pb failed, reason: connect ECONNREFUSED 127.0.0.1:30000
at BrowserHTTPRequest.<anonymous> (.../node_modules/#tensorflow/tfjs-core/dist/io/browser_http.js:128:31)
at step (.../node_modules/#tensorflow/tfjs-core/dist/io/browser_http.js:32:23)
at Object.throw (.../node_modules/#tensorflow/tfjs-core/dist/io/browser_http.js:13:53)
at rejected (.../node_modules/#tensorflow/tfjs-core/dist/io/browser_http.js:5:65)
at process.internalTickCallback (internal/process/next_tick.js:77:7)
(node:23291) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:23291) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Note: the code works if modelUrl and modelWeights are valid url pointing to existing resources.
Node-2: the code is executed as part of a custom block for Node-Red.
If you don't find any other solution you can catch the error on the top level like this:
process.on('uncaughtException', function (err) {
console.error(err);
});
In there you can get more specific to only catch your specific error.
This is in the process of being addressed at https://github.com/tensorflow/tfjs-core/pull/1455.
Im using mssql with npm
https://www.npmjs.com/package/mssql
for the start i needed to insert to only one table.
so this is how i used:
const pool_db1 = await sql.connect(config);
pool.request()
.input('input_parameter',element.CustomerID)
.query('INSERT ..')
Now i need to insert some data for one more table that located in different Databases.
So basically i have 2 configs files.
i tried to add
const pool_db1 = await sql.connect(config);
const pool_db2 = await sql.connect(config2);
i know i can SQL.close() one connection and then sql.connect() to another,
but i want another solution because this INSERT to tables happend async for more tables(in the same connection),
so i need those 2 connection to be open but it dosent seems to open 2 connection.
error below:
(node:13888) UnhandledPromiseRejectionWarning: Unhandled promise
rejection (rejection id: 1): Error: Global connection already exists.
Call sql.close() first. warning.js:18 (node:13888) [DEP0018]
DeprecationWarning: Unhandled promise rejections are deprecated. In
the future, promise rejections that are not handled will terminate the
Node.js process with a non-zero exit code.
Apparently when you use sql.conenct you are using the lib in a global scope way, checking docuemntation I found the ConnectionPool method, try:
const pool_db1 = await new sql.ConnectionPool(config).connect();
const pool_db2 = await new sql.ConnectionPool(config2).connect();