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

Support to invoke user defined callbacks inside WASM component from wasmtime #412

Open
BrytonLee opened this issue Nov 11, 2024 · 2 comments

Comments

@BrytonLee
Copy link

Programs like eBPF usually hire a callback function to let underlying framework to invoke it when a certain kind of event happened, to support this in WASM component model, it would be very useful to enable developers coding WASM component with callbacks.

Current WASM component model doesn't have an appropriate keyword/primitive to support that, and wasmtime doesn't support reentrance to WASM component.

@lukewagner
Copy link
Member

Sorry for the slow reply due to WasmCon, and thanks for filing.

I think you're right that we probably need a callback type in WIT. Another use case is discussed in #223. The main concern with callbacks is that, in cross-component/language scenarios, callbacks tend to immediately lead to cyclic leaks unless there is a global garbage/cycle-collector, which we don't have. However, near the end of #223 I was realizing that if we scope callbacks (to a call or a parent resource), then we can perhaps avoid the cycles by design. I haven't had time to focus on this recently, but after Preview 3 is finished, I am interested to focus on adding callbacks.

Separately, there is an Async.md#TODO to add a reentrant (or maybe recursive... exact name TBD) attribute on function types allowing them to opt into being called recursively. This is a simpler addition than the full callback type and so could be added sooner.

@BrytonLee
Copy link
Author

Thank you @lukewagner , I am glad to hear you also support this proposal. Looking forward to see callbacks to be added to WIT.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants