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
MessagePort, MessageChannel and StructuredClone implementation #3521
base: main
Are you sure you want to change the base?
Conversation
…Impl constructor parameter
…ges enqueuing if PMQ has not been enabled yet
Hey @domenic, sorry for tagging you but I don't know who else to tag. Two weeks have passed. Did you perhaps have a chance to check for my work? Thank you |
I think the next step is seeing if you pass the relevant tests. Since I notice you're implementing the structured clone algorithm as part of this, perhaps the simpler starting point would be to implement and pass the tests for |
@domenic thank you for your reply. So, perhaps would it be better to move structured cloning functions to a different file and folder, outside of Should I honor the URL path? Like, if the docs url is https://html.spec.whatwg.org/#dom-structuredclone, the folder should be |
… to a different file
…ialization for DataView
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is impressive work; thanks! To be clear though, I was suggesting one single PR to land structured clone, and then later on top of that build MessagePort/MessageChannel. I'll review just the structured clone parts for now.
However, the biggest work here is getting the tests to pass. As you can see from CI, there's still a good amount of issues with the algorithm.
Good luck!
lib/jsdom/living/structured-clone/structuredDeserializeWithTransfer.js
Outdated
Show resolved
Hide resolved
/** | ||
* Let memory be an empty map. | ||
* Let transferredValues be a new empty List. | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's best not to copy the spec, since it gets out of date over time. Instead just provide a single-line comment linking to the relevant spec, so people can compare the spec and the code side-by-side.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I copied it almost everywhere ahah.
I think we might keep them until the last moment. I mean, I do not expect specs to change in short time. Wdyt?
lib/jsdom/living/structured-clone/structuredDeserializeWithTransfer.js
Outdated
Show resolved
Hide resolved
lib/jsdom/living/structured-clone/structuredDeserializeWithTransfer.js
Outdated
Show resolved
Hide resolved
lib/jsdom/living/structured-clone/structuredDeserializeWithTransfer.js
Outdated
Show resolved
Hide resolved
Thank you! It is fine to me. I mean, structuredClone is the biggest part now. I don't think it is needed to get back and open another pr for these two. I mean, they are... "entangled" (like MessagePorts 😄). |
Hey @domenic, I hit a wall that I honestly don't really know how to bypass. Among the tests I found this one: What follows is given that I had to convert serialization By converting the I found that both Map and Objects treat I see that both numbers can be checked by using Also, converting -0 to be a string is not a viable way. Do you, perhaps. have any possible solution to this? Thank you. |
…its records to be a string to support -0
Okay, nvm. I found that using |
Hey there @domenic, I just hit another wall. This one is thicker this time. These are the tests that are now failing and that I don't know how to solve them: Open the list
As you might notice the biggest topics here are:
Growable / Resizable ArrayBuffers are not supported in Node yet. I don't know how could this be implemented in JSDOM if so and I don't know if I can go on somehow. So these kinds of tests will always fail until a Node version will support these features. I honestly don't know how to verify if something is a platform object. The specification is quite vague and refers to IDL, which means that every single native object should probably get defined in the code in a completely arbitrary way, but I don't know the current situation of JSDOM nor a full list of Serializable and non-serializable objects (is there an index somewhere?). I don't know if all the native classes are implemented inside JSDOM and if so how to interact with them. The final biggest point is about detaching buffers. So, how should buffers get detached in your opinion? I didn't find a correct way, other than Other than the points above, there are some undefined methods that I didn't dig into to understand what was the issue (like Also, there's a specific point where I literally said "WTF?".
I honestly cannot figure out how a deleted reference from the global object can get retrieved from a function like "structureDeserialize", which receives the So, I cannot go on with this PR without finding out how to fix these three points. My current idea is that we'll get forced to ignore some tests. Let me know, |
Hey @domenic, sorry again for tagging you, but I'd like to bring this on, but I'm locked right now. Thank you! |
Hey, I'm sorry, but the point of needing PRs that pass the tests is that I don't have time to do feature development. That includes helping others with their code for feature development. Maybe you can find a collaborator, but unfortunately I don't have the time to do more than review and merge PRs that already meet the project requirements of passing the test suite. Getting it to pass needs to be done by you! |
@domenic I see your point. First of all, thank you for your reply. I'll try to figure out a way to fix those things or ignore the tests. |
https://nodejs.org/en/blog/announcements/v20-release-announce supports resizable? |
Hi there! I was in need of testing my implementation for a system based on
postMessage
s andMessageChannel
s but noticed there wasn't an implementation insidejsdom
.I started looking around in issues and pull requests and found these issues and failed attempts:
So based on the comments in the discussions above, I decided to fork jsdom and attempt to implement both of them.
Of course, this is an untested and maybe quite incomplete implementation, but I tried to made it to follow the standard.
So, I'm opening this draft PR to let you know I'm working on it and because, as this is my first PR here, I'd like to receive an early feedback and some guidance about the next steps, because I had a few difficulties with testing and so on.
I hope this attempt is appreciated and I'm really looking forward into collaborating with the community to bring this into production.
Thank you!
Closes #3363
Closes #3287