Skip to content

Conversation

@bennostein
Copy link
Contributor

@bennostein bennostein commented Nov 22, 2024

This was causing some issues in one of my examples, as pointers copied over through proxy objects were outliving the actual object in the skip heap. Thanks Daniel for the help debugging!

@bennostein bennostein marked this pull request as draft November 22, 2024 13:49
@bennostein bennostein marked this pull request as ready for review November 22, 2024 14:05
return value;
if (typeof value == "object") {
if (value === null) return value;
if (isObjectProxy(value)) return value.clone() as T;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why call clone here instead of in deepFreeze? Do we need a distinct clone for each time it gets checked? If it needs to be here, then check is confusingly misnamed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My understanding (@skiplabsdaniel is the authority) is that this is a distinct issue from deep-freezing: these proxy objects are frozen, but when they're used as parameters to mappers and resources, their skip-heap pointers can outlive the lifetime of the objects they point to. So it's not always necessary to clone when freezing: only at this point when the proxy is used as a parameter.

Agreed on the naming point, will change.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, but I don't understand. :-) Is it a pointer stored in the skip heap to a proxy object in the js heap that is the problem? Is the proxy in the js heap really just supposed to be a wrapper for a skip object? So would it make sense to have the skip heap hold a pointer the the proxied skip object instead?

It isn't clear how calling clone here will make a difference to the relative lifetimes. I worry that this is a bug waiting to happen since the clone call looks like a nop and someone could easily remove it later.

@bennostein bennostein merged commit b1255f1 into SkipLabs:main Nov 22, 2024
5 checks passed
bennostein added a commit that referenced this pull request Nov 22, 2024
(stacked on #519)

Adds a runnable version of the getting started example and applies a
handful of unrelated bug fixes and cleanups.

Run as follows:
```
cd skipruntime-ts
make bunbuild
bun run examples/groups.ts &
bun run examples/groups-server.ts &
bun run examples/groups-client
```
@bennostein bennostein deleted the clone-proxied-params branch November 28, 2024 10:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants