You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
(async () =>{
async function fun1(){
let f1 = "D:\\a1.xlsx"
const res1 = await alasql.promise(`select * from xlsx(?) limit 100000`, [f1])
return res1
}
async function fun2(){
let f2 = "D:\\a2.xlsx"
const res2 = await alasql.promise(`select * from xlsx(?) limit 100001`, [f2])
return res2
}
try{
const orderData = await Promise.all([fun1(), fun2()])
console.log(orderData)
}catch(error){
console.error(error);
}finally{
console.log('end');
}
})()
I have an issue where I've created two asynchronous functions, fun1 and fun2, and I want to execute them in batch using Promise.all, passing parameters f1 and f2 to the xlsx(?) placeholder.
When running these functions individually, the query results are correct.
However, when I put them into Promise.all, no results are returned, and no errors are thrown.
After repeated testing, I found that if there is nothing after xlsx(?) in Promise.all, no results are returned. But if I add a limit and the number after limit is different for each function, the correct results are obtained. Yet, if the numbers after limit are the same, no results are returned again.
For example, in the code above, if both are limit 1000, no results are returned. But if one is limit 1000 and the other is limit 1001, the correct results can be obtained.
What could be the reason for this?
The text was updated successfully, but these errors were encountered:
Hmmm. Very strange. I am wondering how the timing of these two functions might affect each other. Hmmmmmmm...
Im wondering if running async commands via a queue instead will affect this. It will effectively make multiple queries run in sequense, but getting incorrect results is worse.
I reviewed the issue you reported and made some adjustments to the code to address it. Here’s the updated solution:
(async () => {
async function fun1() {
let f1 = "D:\\a1.xlsx";
try {
console.log('Running fun1 with', f1);
const res1 = await alasql.promise(`select * from xlsx(?) limit 100000`, [f1]);
console.log('Result from fun1:', res1);
return res1;
} catch (error) {
console.error('Error in fun1:', error);
throw error; // Re-throw to be caught in the main try-catch block
}
}
async function fun2() {
let f2 = "D:\\a2.xlsx";
try {
console.log('Running fun2 with', f2);
const res2 = await alasql.promise(`select * from xlsx(?) limit 100001`, [f2]);
console.log('Result from fun2:', res2);
return res2;
} catch (error) {
console.error('Error in fun2:', error);
throw error; // Re-throw to be caught in the main try-catch block
}
}
try {
console.log('Starting batch execution');
const orderData = await Promise.all([fun1(), fun2()]);
console.log('Batch results:', orderData);
} catch (error) {
console.error('Error in Promise.all:', error);
} finally {
console.log('End');
}
})();
Explanation:
Main File: The updated code performs queries on Excel files with different limits in parallel.
Error Handling: Added additional logging to detect and handle errors during execution.
Testing: Make sure to test the functions individually and adjust limits if needed.
I have an issue where I've created two asynchronous functions, fun1 and fun2, and I want to execute them in batch using Promise.all, passing parameters f1 and f2 to the xlsx(?) placeholder.
When running these functions individually, the query results are correct.
However, when I put them into Promise.all, no results are returned, and no errors are thrown.
After repeated testing, I found that if there is nothing after xlsx(?) in Promise.all, no results are returned. But if I add a limit and the number after limit is different for each function, the correct results are obtained. Yet, if the numbers after limit are the same, no results are returned again.
For example, in the code above, if both are limit 1000, no results are returned. But if one is limit 1000 and the other is limit 1001, the correct results can be obtained.
What could be the reason for this?
The text was updated successfully, but these errors were encountered: