I have an electron app using ipc between the main process and renderer process. This is not a production build. Right now I'm just trying to do something simple: Display a SQL query on the page when the user presses a button. I've had this figured out for a while now, but for the love of me, I cannot figure out why this crashes when I try to distribute it to other users. I've tracked the issue down to msnodesqlv8, as everything works fine without it. When I require it in the global scope of main.js, the app crashes on startup. When its in the scope of the function called by the button's onclick event, it crashes when the button is clicked. I've already ensured that they have access to the database, like I do. Here's the function:
function executeQuery(connectionString, queryString) {
const sql = require('msnodesqlv8');
return new Promise((resolve, reject) => {
sql.query(connectionString, queryString, (err, results) => {
if (err) {
reject(err);
return;
}
resolve(results);
});
});
}
And the function that calls it, both in main.js:
async function handleQuery() {
const connectionString = "Driver={SQL Server};Server=<Server>;Database=<Database>;Trusted_Connection=Yes;TrustServerCertificate=Yes;";
const query = "SELECT * from <Table> WHERE <Attribute> = <Value>";
//Runs
let result = await executeQuery(connectionString, query);
console.log(result)
return result;
}
I am using Electron-Fe to make the app. Every time I try reinstalling msnodesqlb8, I make sure to rebuild it using .\node_modules\.bin\electron-rebuild.cmd
. Using npm list -g
only outputs -- [email protected]
Again, when I make it and run Setup.exe locally, it works, and the page displays the result of the SQL query. When others run Setup.exe, it works until const sql = require('msnodesqlv8');
is reached, then crashes.
At the very least, is there a way to generate crash reports for my users so I can see what's going on?
I have an electron app using ipc between the main process and renderer process. This is not a production build. Right now I'm just trying to do something simple: Display a SQL query on the page when the user presses a button. I've had this figured out for a while now, but for the love of me, I cannot figure out why this crashes when I try to distribute it to other users. I've tracked the issue down to msnodesqlv8, as everything works fine without it. When I require it in the global scope of main.js, the app crashes on startup. When its in the scope of the function called by the button's onclick event, it crashes when the button is clicked. I've already ensured that they have access to the database, like I do. Here's the function:
function executeQuery(connectionString, queryString) {
const sql = require('msnodesqlv8');
return new Promise((resolve, reject) => {
sql.query(connectionString, queryString, (err, results) => {
if (err) {
reject(err);
return;
}
resolve(results);
});
});
}
And the function that calls it, both in main.js:
async function handleQuery() {
const connectionString = "Driver={SQL Server};Server=<Server>;Database=<Database>;Trusted_Connection=Yes;TrustServerCertificate=Yes;";
const query = "SELECT * from <Table> WHERE <Attribute> = <Value>";
//Runs
let result = await executeQuery(connectionString, query);
console.log(result)
return result;
}
I am using Electron-Fe to make the app. Every time I try reinstalling msnodesqlb8, I make sure to rebuild it using .\node_modules\.bin\electron-rebuild.cmd
. Using npm list -g
only outputs -- [email protected]
Again, when I make it and run Setup.exe locally, it works, and the page displays the result of the SQL query. When others run Setup.exe, it works until const sql = require('msnodesqlv8');
is reached, then crashes.
At the very least, is there a way to generate crash reports for my users so I can see what's going on?
Share Improve this question asked Mar 20 at 18:29 weirdfishesweirdfishes 1 1- It's a native module and it's probably not being bundled properly into your packaged app. – Slbox Commented Mar 20 at 22:30
1 Answer
Reset to default 0You can try piggy backing on the node process event 'uncaughtException', it usually works in electron.
Write the error to a file you can read and then exit like so
process.on('uncaughtException', (err) => {
let crashLog = [];
if(err instanceof Error) {
[ 'message', 'stack' ].forEach((prop) => {
crashLog.push(`${prop}: ${err[prop]}`);
}
}
else if( err.toString() )
crashLog.push(err.toString());
else
crashLog.push('Unspecified uncaught exception');
require('fs').writeFileSync(
'/path/to/crash/log',
crashLog.join('\r\n')
);
process.exit(1);
});
Node doc
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744390182a4571868.html
评论列表(0条)