-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Closed
Description
While investigating an unrelated issue with my Node.js project's use of WASM, I noticed that node_shell_read.js's readAsync function is not, in fact, async.
I believe this is because changes made in #23120 are incorrect:
- Previously, it was a non-
asyncfunction that returned a Promise that invokedfs.readFile. - Now, it's an
asyncfunction that invokesfs.readFileSync.
However, marking a function async doesn't mean that function calls within it are automatically made async; it only means that you can use the await keyword to invoke already async code, instead of having to mess with promises and callbacks. Calling fs.readFileSync will still block the Node.js event loop while it's evaluated, just as if readAsync weren't marked async.
To fix this:
- Either go back to the pre-Use async/await for internal readAsync function. NFC #23120 approach of calling a promise that invokes
fs.readFile. - Or invoke
fsPromises.readFile, which is async and can be used withawait.
Version of emscripten/emsdk:
4.0.11-git
Full link command and output with -v appended:
/opt/homebrew/Cellar/emscripten/4.0.11/libexec/em++ @CMakeFiles/build.dir/includes_CXX.rsp -O3 -DNDEBUG -std=gnu++17 -sDISABLE_EXCEPTION_CATCHING=0 -MD -MT CMakeFiles/build.dir/src/test.cpp.o -MF CMakeFiles/build.dir/src/test.cpp.o.d -o CMakeFiles/build.dir/src/test.cpp.o -c /Users/josh/src/project/src/test.cpp
Metadata
Metadata
Assignees
Labels
No labels