Neutralino.filesystem.getStats() not async
Craftidore opened this issue · comments
Neutralino.filesystem.getStats() not async
Expected Behavior
let stats = await Neutralino.filesystem.getStats('C:\\valid\\path');
should run fine, according to the docs
Actual Behavior
await
also brings up the same error when I use it before any other function from Neutralino.os
or Neutralino.filesystem
namespace.
Steps to Reproduce the Problem
- run
neu create "app-name"
in shell - replace main.js code with the following:
// This file should be called *after*
function onWindowClose() { //can close
Neutralino.app.exit();
}
Neutralino.init();// initialize the app
Neutralino.events.on("windowClose", onWindowClose); // makes the app close
try {
let appData = await Neutralino.os.getPath('data');// this throws error
console.log(appData);
let stats = await Neutralino.filesystem.getStats(appData);// if I remove the `await` from the `Neutralino.os.getpath` call, this will throw the same await error.
} catch (error) {
console.log(error);
}
Specifications
- NeutralinoJs Binaries Version: v4.0.0
- NeutralinoJs Client Version: v3.0.0
- NeutralinoJs CLI Version: v8.0.0
- Platform: Windows 11 (OS build 22000.318)
I also tried running the code without the await arguments entirely, and an unhelpful error message
{
"code": "NE_RT_NATRTER",
"message": "Native method execution error occurred. Failed because of: Unknown exception. Make sure that you've provided required parameters properly."
}
Hello. Please note that if you need to use await
you have to wrap it with an async
function. Here you need to make an async IIFE since you are calling await
from the top of the scope.
(async () => {})(
let itWorks = await Neutralino.filesystem.getStats(NL_PATH);
);
Or use promises if you like,
Neutralino.filesystem.getStats(NL_PATH)
.then((itAlsoWorks) => {
});