Skip to content

readAsync isn't async #24813

@joshkel

Description

@joshkel

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-async function that returned a Promise that invoked fs.readFile.
  • Now, it's an async function that invokes fs.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:

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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions