erksch
RustyV8: Example of using PromiseResolver / async?
@bartlomieju Oh, very nice, that makes sense. Thanks a lot!
I was thinking that the result of the js call would be saved to the scope, which would be released before the callback is executed, so that I would need to run it in a special callbackscope that is then destroyed with the callback, but apparently this works.
16 replies
RustyV8: Example of using PromiseResolver / async?
@bartlomieju
When I call a JS function that returns a promise, polling if the promise has finished is expensive.
So I implemented a callback on .then, but it needs both the promise and the oneshot sender, so I'm embedding it as data:
Unfortunately this either causes a
1) use-after-free, if I create a short-lived scope (callback outlives it)
2) memory leak
I tried to use CallbackScope but that isnt accepted as a scope arg.
What's the right approach?
Basically I want all of the above to get dropped only when the callback has finished.
16 replies
RustyV8: Example of using PromiseResolver / async?
@bartlomieju I managed to get it all to work, but it was quite a fight 🫠
I did manage to implement bidirectional async without MaskFutureAsSend, so that's something 🥂 Can I get back to you if I face another blocking issue? I realize this is a Deno support forum and not really for RustyV8 🙂
I did manage to implement bidirectional async without MaskFutureAsSend, so that's something 🥂 Can I get back to you if I face another blocking issue? I realize this is a Deno support forum and not really for RustyV8 🙂
16 replies
Embedding RustyV8: Fatal JavaScript out of memory: Reached heap limit
Indeed that solved the issue.
@bartlomieju
I was thinking about implementing a custom deserializer (e.g. from bincode), and did a trivial benchmark of String::new, but it seems rather slow? I assume the V8 deserializer has a more direct/lowlevel approach? Would it be feasible to do in Rust using the RustyV8 bindings?
4 replies