Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FFI: Errors cannot be thrown after a nonblocking function call #18131

Open
roj1512 opened this issue Mar 11, 2023 · 2 comments · May be fixed by #18436
Open

FFI: Errors cannot be thrown after a nonblocking function call #18131

roj1512 opened this issue Mar 11, 2023 · 2 comments · May be fixed by #18436
Labels
bug Something isn't working ext/ffi related to ext/ffi needs investigation requires further investigation before determining if it is an issue or not

Comments

@roj1512
Copy link
Contributor

roj1512 commented Mar 11, 2023

call_some_nonblocking_function();
console.debug("Reaches here.");
throw new Error(); // not thrown
@littledivy littledivy added bug Something isn't working needs investigation requires further investigation before determining if it is an issue or not ext/ffi related to ext/ffi labels Mar 22, 2023
@roj1512
Copy link
Contributor Author

roj1512 commented Mar 25, 2023

Full reproduction example: https://github.com/roj1512/deno-18131-reproduction

andreubotella added a commit to andreubotella/deno that referenced this issue Mar 25, 2023
Tokio's `spawn_blocking` allows running blocking operations, which in
Deno include file I/O and "non-blocking" FFI, in a thread pool
separate from the thread running the JS event loop. However, by
default, when the tokio runtime is dropped, it will block on the main
thread until all such blocking operations have completed.

This is a problem, since a non-blocking FFI call might never actually
finish, which would keep the Deno process running forever, even if it
would otherwise have finished earlier because of an uncaught
exception. This change, therefore, sets a time limit of 0.5 seconds to
wait for those blocking tasks to finish.

Closes denoland#18131.
@aapoalas
Copy link
Collaborator

This seems to be essentially the same issue as #14333 just with different API triggering the behaviour.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working ext/ffi related to ext/ffi needs investigation requires further investigation before determining if it is an issue or not
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants