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

feat: Add bindings for {Dis,}allowJavascriptExecutionScope #862

Merged
merged 6 commits into from
Jul 19, 2023

Conversation

andreubotella
Copy link
Contributor

I've got the raw functionality working, but I'm not sure at all about the API and the lifetimes/generics. For the time being I've managed to patch something that works for the ValueDeserializer use case, but I'm not sure at all that it's any good.

Closes #833.

@andreubotella
Copy link
Contributor Author

@piscisaureus PTAL

@andreubotella
Copy link
Contributor Author

This is not ready for merging – the generics probably need changes, and I didn't add tests to scope.rs because they'd probably have to be reworked after the changes – but it is ready for review.

Copy link
Contributor

@bnoordhuis bnoordhuis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes LGTM, I don't really have complaints. Perhaps @piscisaureus should look it over.

src/scope.rs Outdated Show resolved Hide resolved
@piscisaureus
Copy link
Member

Looking good so far.
By the look of it, it seems possible to create a HandleScope inside a Disallow scope. Is that intentional?
What about creating a Disallow scope inside a Disallow scope?
And what about creating an Allow scope inside another Allow scope?

@andreubotella
Copy link
Contributor Author

It should be possible to create a TryCatch inside an Allow scope, and I guess it might be useful to have a TryCatch inside a Disallow scope created with ThrowOnFailure, to prevent JS code from being run but not throw an exception. It would not make sense to create an Allow scope inside another Allow scope, but I guess a Disallow inside a Disallow of a different type might make sense.

The main reason why I'm allowing creating a HandleScope inside a Disallow scope, and not requiring an Allow scope to have a Disallow parent in the type system is because ValueDeserializerImpl::read_host_object takes a HandleScope that in the C++ side is a child of a Disallow scope, and it must be possible to create a child Allow scope in the implementation. But I guess changing the passed type might simplify things?

@aapoalas
Copy link
Contributor

Are there any blockers for this?

@andreubotella
Copy link
Contributor Author

Are there any blockers for this?

Rebasing and a thorough review from @piscisaureus I guess. But I haven't looked at this PR in over a year, and scopes are complicated.

@andreubotella
Copy link
Contributor Author

andreubotella commented May 1, 2023

Rebased. Since this PR is one of the blockers for denoland/deno#12067, which is lately gaining prominence due to Deno KV, it would be good to put some more work into this. However, I don't fully understand the details of how scopes are meant to work together, in terms of creating scopes from other scopes and as/deref, and my understanding of those details has certainly not grown in the year that this PR has been open. So a lot of help from @piscisaureus would probably be needed before this PR can be landed.

@ry
Copy link
Member

ry commented Jul 1, 2023

Closing because it's very old. Please open a new PR if you want to continue this.

@ry ry closed this Jul 1, 2023
@andreubotella
Copy link
Contributor Author

andreubotella commented Jul 1, 2023

I last rebased this PR two months ago. The single merge conflict is trivial, and after resolving it, the tests pass. Is that too old, really?

The issue this PR fixes is a main blocker for structured cloning and serializing web APIs, which I would have assumed is of high relevance to the Deno company lately because of Deno KV. But recently I haven't seen much interest from Deno in getting this PR landed, even though at this point the ball was on Deno's court, see #862 (comment).

At this point, I don't have the motivation to reopen this. If anyone does, feel free to take this code, and I would appreciate it if you would ping me in the resulting PR.

@bartlomieju bartlomieju reopened this Jul 17, 2023
@bartlomieju
Copy link
Member

Hey @andreubotella, sorry for the miscommunication. I'm still very interested in landing this PR - sorry I hadn't picked it up earlier, it slipped in my backlog.

The only thing Bert wanted before merging this one was an update to deref_types test from src/scope.rs. I will prioritize getting it done this week.

@bartlomieju bartlomieju changed the title [WIP] Bindings for {Dis,}allowJavascriptExecutionScope feat: Add bindings for {Dis,}allowJavascriptExecutionScope Jul 17, 2023
@bartlomieju
Copy link
Member

bartlomieju commented Jul 18, 2023

@andreubotella I added more test cases in deref_types() test. I'll wait a couple days for Bert to take a look and then land the PR.

EDIT: I just need to update the comment in scope.rs and we're good to merge provided the CI passes. Will circle back tomorrow.

Copy link
Member

@bartlomieju bartlomieju left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thank you @andreubotella

@bartlomieju bartlomieju merged commit f360663 into denoland:main Jul 19, 2023
@andreubotella andreubotella deleted the allow-scopes branch August 6, 2023 23:17
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

Successfully merging this pull request may close these issues.

Add bindings for AllowJavascriptExecutionScope
6 participants