-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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(js): add check to no_modules gen js for cloudflare workers #1384
Conversation
For the record, the reason for this strange behavior is that the module comes from a different JS context, and the primordials in each context are, unfortunately, considered to be different objects. So it is an instance of A similar issue would happen in browsers when passing modules between (same-origin) windows or frames. |
Thanks for the PR @ashleygwilliams and explanation @kentonv! I wonder if we might be best getting by by inverting the conditional though? I think that I think that'd also have the nice bonus of solving the cloudflare issue b/c the object passed in definitely isn't a string, so it'd hit the final branch of |
@alexcrichton yeah i definitely agree, good call. i'll update this PR. |
@alexcrichton What if someone is passing in an instance of |
Hm that's true yeah, and switching may end up breaking someone, but I kinda like the sound of "special case going to |
@alexcrichton yeah i think that is why i also felt it was a good idea. it's definitely the case that i'd also want to avoid a large set of conditionals. that being said, we might be moving into "different feature" territory. how do folks feel about me fixing this PR to pass and then filing and fixing this expressivity issue in a separate PR? (we can go through and think through all the cases there) |
feec4ed
to
4b4812f
Compare
I think I'd personally still prefer to switch the order of the clauses, executing |
Oh, I forgot about a more obvious one: Maybe just check for (Obviously, I'm just a spectator here so also feel free to ignore me.) |
@kentonv one of us! one of us! spectators are extremely welcome. no need to apologize! i think that's a great plan and i'm working on it now. @alexcrichton this test sitch.. looks like these errors are unrelated to the PR? i think you're working on this actively right now, but lemme know if i'm mistaken. |
4b4812f
to
3e814a6
Compare
👍 |
Ah yeah the errors are unrelated to this, so no worries about those |
Just for the record, another option could've been to use a string tag-based check that is commonly used in JS for such cross-realm checks: Object.prototype.toString.call(module_or_path) === '[object WebAssembly.Module]' |
@RReverser yeah that was the original plan, but in talking with @alexcrichton we realized that we much preferred making the conditional prioritize the more exceptional case (fetch), and letting instantiate be the catch all (as it's the more general case). |
No description provided.