TypeError: filehandle.read is not a function
31 October 2023 at 10:58 pm
Just a quick post to let others solve this. If you have a JS file using promises and get errors that say that “filehandle.read is not a function” (or any other variant of that for other calls based on the filehandle) it might be for the same reason that I found.
The solution is really simple. I just forgot to “await” when I created the file handle, so it basically wasn’t ready when I accessed it.
let filehandle = files.open(path, "r");
Changed it to:
let filehandle = await files.open(path, "r");
So hard to see such a small omission, right?