Skip to content
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

Augment structured serialize algorithm to optionally compute a canonical serialized length to allow cross-browser consistent data limits #4914

Open
asutherland opened this issue Sep 16, 2019 · 0 comments
Labels
interop Implementations are not interoperable with each other topic: serialize and transfer

Comments

@asutherland
Copy link

There are a number of APIs where it makes sense to allow storage of arbitrary content-supplied data and structured serialization is the logical choice. In many of these cases, it makes sense to bound the data used because 1) the "normal" usage is expected to be small and reasonable and 2) there's a high chance that the data needs to be synchronously available and so will be stored in memory at all times, potentially multiple times.

Currently the structured serialization algorithm specifies what data gets encoded, but the underlying byte encoding is not specified and is appropriately implementation-dependent. Using the underlying implementation-specific buffer sizes would lead to potential browser compatibility issues where a data payload that was under the limit in one browser might throw in another browser.

So I propose that we augment the structured serialization algorithm so that it optionally computes a canonical serialized length that grows in rough proportion to the growth of included data and the underlying implementation-specific encoding. The key feature is cross-browser consistency, not being close to actual implementation usages.

This (establishing a limit) has come up previously in discussion around:

Existing APIs that use structured clone to add ad-hoc storage:

cc: @annevk

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
interop Implementations are not interoperable with each other topic: serialize and transfer
Development

No branches or pull requests

2 participants