-
Notifications
You must be signed in to change notification settings - Fork 286
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
Feature request: loosen try_catch's type to return Result<_, Handle<'a, JsValue>> #630
Comments
@jrose-signal I like this idea and it would be good for the N-API backend, but unfortunately it would be complicated for the legacy backend.
Can you share more about your use case? In my opinion, Thanks! |
I think it just has to be Line 137 in 1f217f5
that gets initialized from pure Rust code here Line 208 in 1f217f5
without C++ doing anything more than passing the pointer down the stack. That should be safe to treat as a mutable borrow, yeah?
Mine's not a tightly-scoped use case, I'm afraid: I'm trying to deal with a Rust-side function throwing during the fulfillment of a JavaScript promise, which older versions of Node just drop on the floor. For now I'm just making a dummy (I've actually made things much harder for myself in the real scenario, but I won't get into that here.) |
That value is used for both the @dherman What are your thoughts? It does seem like a strictly better API, even if it makes the legacy backend more complicated. |
@jrose-signal I put a quick PoC together for this, but I need to think a little more about the correctness of only specifying |
Looks good to me! It's a backwards-compatible change from the legacy backend type to the N-API backend type, so I don't foresee it causing problems for the two backends to have different return types. |
Come to think of it, |
@jrose-signal if it's not unwind safe, how would we keep the panic from propagating over the FFI boundary? As an aside, I think stack unwinding through C++ is handled by Rust even though it's not officially supported. |
I'll admit I've had trouble fully understanding UnwindSafe, but this line from the documentation seems to imply that it'd be okay here:
In this case, your use of |
🤔 That's a good point. Since we do not execute any of the Neon user's code after catching a panic, we should be okay only verifying Neon's invariants. I'll take this under advisement. We may choose to keep it for now since relaxing a trait bound in a public API is easier than adding one. |
I checked with Niko Matsakis and he reassured me that if we re-raise the panic, we can |
(I think in mathematics that was what they call "proof by core team") |
Closed in #631 |
Context::try_catch
's current signature isHowever, nothing in the implementation (as far as I can tell) actually relies on the return value being a JS value. It could just as easily be
The text was updated successfully, but these errors were encountered: