denoland / denoland/deploy_feedback

Support object serialization/deserialization

Open
#662 0 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
No language data
Stars
79
Forks
5
PR merge metrics
No merged PRs in 30d

Description

### What problem are you trying to solve?

I am trying to implement the ability to encrypt/decrypt values being stored in a Deno KV datastore.

Currently, if the source data is byte based (`ArrayBuffer`, typed array, `DataView`) this is relatively trivial. When trying to deal with out cloneable values this becomes difficult.

When cloning, V8 uses its ability to serailize and deserialize objects. The Deno runtime does provides this V8 capability through the non-public API `Deno.core.serialize()` and `Deno.core.deserialize()` but also provides it through the [v8 node built-in polyfill](https://github.com/denoland/deno/blob/36d877be4a220cb30ddf69d43c386ae8d15f4b32/ext/node/polyfills/v8.ts#L74-L79), but neither of these are available on Deploy.

This makes it difficult to store arbitrary cloneable values in an encrypted format that works seamlessly between Deno runtime and Deploy.

### Describe the solution you'd like

I would like Deploy to expose the V8 serialization functions in some fashion.

### Describe alternatives you've considered

Using other user land serialization options that can handle arbitrary values. These are highly inefficient, both from a processing speed perspective but also the resulting size of the serialized object. Some experiments have shown between 10 and 100 times slower than using the V8 serialization APIs in Deno runtime.

### Documentation, Adoption, Migration Strategy

Gaining parity with the Deno runtime would be effectively transparent migration. That being said, formalising `Deno.core` APIs in Deploy is likely not a good idea. Obviously a consistent API could be provided via `node:v8` but again that does feel silly to create a direct dependency on node polyfills. The team should possibly consider formalizing the API was `Deno.v8.serialize()` and `Deno.v8.deserialize()` across both runtime and Deploy.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.