-
Notifications
You must be signed in to change notification settings - Fork 9
prevent circular proxy loop by collapsing immediate‑parent deref links #1656
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
prevent circular proxy loop by collapsing immediate‑parent deref links #1656
Conversation
- add guard in `normalizeAndDiff` cell-link branch: when a link comes from query-result dereferencing and targets the same-doc immediate parent, embed a snapshot via `tx.readValueOrThrow` instead of writing the link - switch snapshot/alias reads to `tx.readValueOrThrow` for transaction consistency
|
if you all prefer to remove the debugging, im happy to do that. |
| options, | ||
| seen, | ||
| ); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does your data looks something like this?
const doc: Cell<List> = {value: 1};
// point next to the top of the doc
doc.key("next").set(doc);I think doc would look like:
{"value": 1, "next": {"/": {"@link1": {"id": "baed", "path": []}}}normalizeAndDiff has the seen map, so I'm curious why it's not sufficient here.
Making the snapshot seems ok, since you're only using it to generate the diff (so you don't have to worry about being wrong if it gets out of sync), but I didn't get why it was required.
Is this a case where we're replacing an object with a link, and that replacement occurs on an $alias?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we turn the "next" value into a link and it looks a bit like this:
[DEBUG][normalizeAndDiff::14:30:46.220] [BRANCH_CELL_LINK] Processing cell link at path=internal.#1.next link={"/":{"link@1":{"path":["internal","#1"],"id":"of:baedreidafjd3rgnpyyxxbwvvf75qc7vk2s5nzsbhw76djm4u2yhwkvptby","space":"did:key:z6MktpWYAnNacQL9AEkhqxaKR1qux7uU5rM6PjBvPst6LEWc"}}}
the problem is that it points to internal.__#1 which causes infinite loop when we traverse later. (and there is no js object for seen to keep track of here)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can add the link to seen, but I think you've also added the object at ["internal", "#1"] to seen as well.
I think this is just that we don't handle circular links correctly everywhere (for example, one of my traverse functions is traverseDAG, since it does not handle them).
I think we're supposed to be supporting cycles, but I have no issue with disabling them here if that's the simplest approach.
normalizeAndDiffcell-link branch: when a link comes from query-result dereferencing and targets the same-doc immediate parent, embed a snapshot viatx.readValueOrThrowinstead of writing the linktx.readValueOrThrowfor transaction consistencySummary by cubic
Prevents a circular proxy loop when a dereferenced link targets its same-doc immediate parent by embedding a snapshot instead of writing the link. Also switches reads to tx.readValueOrThrow for transaction consistency, addressing Linear CT-773.