-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
Expose Deno.core.(de)serialize
as a public API
#12379
Comments
might also be a good idea to expose it as a public api now that ffi supports buffers. |
It is very intentional that they are on What is the use case? |
I need these APIs to pass and return JS values to/from a native library, |
We don't currently support for-storage serialization, meaning that if you serialize |
From what I tested it seems serializing Note: I chose this binary format over JSON because it's easier to parse and likely more efficient, and it supports (de)serializing more type of values, of which I need at the moment is Array Buffer and Views. |
I misspoke, serializing Regardless, making |
Seems like Node.js straight away errors that |
That would no longer be exposing the serialization internals directly, but a version of for-storage (de)serialization, which is used in the web platform for storing serialized values in persistent storage. We don't yet implement for-storage serialization, since Deno CLI doesn't yet implement Indexed DB or any of the other web APIs that use it – but we will probably need to implement it for #10750. So this would be technically feasible. I'll leave it to the core team to decide whether it's worth exposing or not. |
related whatwg/html#3517 |
That is pretty stale, and with structured clone having moved forward, I suspect it is unlikely that it will ever get standardized, at it would require agreement on what the serialization format would be, which would be very specific to the engine, or agreement of the least worst version. Of course if something gets agreement we would be glad to support it, but I wouldn't hold your breath. |
Another reason not to make this public API: V8 sometimes changes the serialize/deserialize format in ways that would be difficult for us to maintain. This has impacted Node.js and Cloudflare Workers already. |
I still feel like eventho it has breaking changes because of a format that is not backwards compatible that it can still be useful in the context of passing stuff from and to shared libraries via the FFI But in that regard I have a repo that supports the latest format used for |
There are many arguments for not exposing it publicly. Respectfully declining. |
With the advent of Deno KV and KV Connect, could you reconsider this? Working with v8-persisted KV values in userland in other Deno processes would benefit greatly from this! |
Deno.core.serialize
andDeno.core.deserialize
seem to serialize and deserialize v8's binary format. I'm working on something that need those functions so I have to use them fromDeno.core
right now, which is not a public API and considered unstable (and it also doesn't have any TS types either).Node.js exposes this functionality through
v8
module: https://nodejs.org/api/v8.html#v8_serialization_apiCould these two functions be exposed as a public API?
The text was updated successfully, but these errors were encountered: