mssql - async function or callback not finished
Posted: Sun Oct 16, 2022 10:41 pm
I'm getting this warning each time timerFired runs on an app I'm working on...
The script execution has ended while an async function or callback in the script might not have finished yet. Please check the script code for unresolved promises or missing await statements.
I've whittled the code down to the following bare minimum. The sp runs a "for xml" query and works perfectly except for the warning. I'm stumped.
The script execution has ended while an async function or callback in the script might not have finished yet. Please check the script code for unresolved promises or missing await statements.
I've whittled the code down to the following bare minimum. The sp runs a "for xml" query and works perfectly except for the warning. I'm stumped.
Code: Select all
import * as sql from "mssql";
async function timerFired(s: Switch, flowElement: FlowElement) {
// create db connection
const sqlConfig: sql.config = {
user: "<uid>",
password: "<pwd>",
database: "<dbname>",
server: "<sqlhost>",
pool: {
max: 10,
min: 0,
idleTimeoutMillis: 3000
},
options: {
encrypt: false, // true for azure
trustServerCertificate: true // change to true for local dev / self-signed certs
}
};
let pool: sql.ConnectionPool = await sql.connect( sqlConfig );
let request: sql.Request = await pool.request();
let result: sql.IProcedureResult<any> = await request.execute( "GetXmlSP" );
let resultXml: string = result.recordset[0]['XML_F52E2B61-18A1-11d1-B105-00805F49916B'];
await flowElement.log( LogLevel.Info, resultXml );
flowElement.setTimerInterval( 1 * 60 );
}