Skip to content

Conversation

@Sytten
Copy link
Contributor

@Sytten Sytten commented Dec 3, 2025

Description of the change

Use the https://github.com/rquickjs/rquickjs-serde

Why am I making this change?

This is just a proposal to see if the test passes. If so it would be nice to centralize around a shared implementation.
Happy to give you guys access to the repository to publish new versions.

@jeffcharles
Copy link
Collaborator

Looks like the stringify/value-array-abrupt.js tests are failing. There's probably other test262 tests that are failing but it stops executing the test262 suite after the first failure.

@jeffcharles
Copy link
Collaborator

For reference, if you checkout all Git submodules in the project and run make ci, that should run roughly the same operations as GitHub's CI.

@Sytten
Copy link
Contributor Author

Sytten commented Dec 4, 2025

Will try it

@Sytten
Copy link
Contributor Author

Sytten commented Dec 7, 2025

@jeffcharles All test are passing now, the issues were:

  • BigInt default to String serialization (fixed with a new strict mode in rquickjs-serde)
  • Error string comparison not having the JSError prefix (fixed by adding the prefix + a comment to not remove it in rquickjs-serde)

@jeffcharles
Copy link
Collaborator

I'll ask @saulecabrera to review since he wrote the serde pieces.

pub fn stringify(val: Value<'_>) -> Result<Vec<u8>> {
let mut output: Vec<u8> = Vec::new();
let mut deserializer = Deserializer::from(val);
let mut deserializer = Deserializer::from(val).with_strict();
Copy link
Member

Choose a reason for hiding this comment

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

Not to block this PR, but looking at the commentary around with_strict

The implementation tries to make smart guesses when it can, for example the deserializer will fallback to converting BigInt to String. This is likely not what you want if you implement a serialization that is JSON compliant.

This is s why we offer the strict mode, that will stick to what the behaviour that the Javascript specification defines for JSON. Just switch the method to use it.

Would you consider making the default implementation be the compliant one and make the lossy one opt-in (and potentially unsafe)?. It seems like a potentially footgun otherwise.

Copy link
Member

@saulecabrera saulecabrera left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for putting this together. Given Javy's dependency on JSON, before landing this PR would you mind adding us as collaborators on the repo and ideally also in crates.io?

@Sytten
Copy link
Contributor Author

Sytten commented Dec 10, 2025

@saulecabrera @jeffcharles Done, you should have received an invite.
The crates is handled automatically via CICD so I think we are good for that, I think should also join the discord of rquickjs (https://discord.gg/TCZEVSKHXd) so its faster if you need to contact me.

@saulecabrera
Copy link
Member

Thanks!

@saulecabrera saulecabrera merged commit a698176 into bytecodealliance:main Dec 10, 2025
5 checks passed
@Sytten Sytten deleted the ef-rquickjs-serde branch December 10, 2025 02:28
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.

3 participants