Open Bug 1991095 Opened 1 year ago Updated 1 year ago

Allow for more more nesting in wexbext objects

Categories

(Application Services :: Webext Storage, defect, P2)

Tracking

(Not tracked)

People

(Reporter: bdk, Unassigned)

References

Details

(Whiteboard: [fxsync-])

serde_json currently has a recursion limit of depth=128 for objects. This is smaller than whatever limit the browser has and so it can cause issues with webext-storage.

We could try to disable the limit, but that's not so easy:

  • You still have to avoid blowing up the stack, which means using something like serde_stacker to dynamically increase the stack. This feels pretty terrifying to me.
  • You also have to avoid blowing up the stack when you call drop on the top-level object. See the carefully_drop_nested_arrays function at the top of that docs.rs page.

Alternatively, I think we should just avoid the depth in the first place. Instead, we can treat storage objects as a JSON object, where each value is the raw JSON string rather than the parsed object. AFAICT, we only care about the top-level values when merging so this should be okay. We should probably still validate the JSON strings in some way.

I can think of 2 ways of doing this:

  • At the browser level. We update the JSON code to call JSON.stringify on all the values of the top-level object. I think this is the simplest solution, but I'm not totally sure how the JS code works.
  • At the rust level. When we parse the JSON, we don't create a fullly-nested object. I think this means using something like https://crates.io/crates/struson to do the parsing. In this case, we still need to be careful to not avoid blowing up the stack (i.e. our validation/parsing functions should not be recursive).
Whiteboard: [fxsync-]
Severity: -- → S3
Priority: -- → P2
You need to log in before you can comment on or make changes to this bug.