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

Uncaught (in promise) DOMException: Proxy object could not be cloned. #489

Open
michael-learns opened this issue Feb 4, 2025 · 10 comments

Comments

@michael-learns
Copy link

I'm getting this issue:

Image

I'm trying to insert my data like so

Image

DB definition is based on below

Image

With the drizzleSchema being

Image

And the schema of the inventory purchase is

Image

I'm using drizzle-orm/sqlite-core

@Chriztiaan
Copy link
Contributor

Chriztiaan commented Feb 4, 2025

Hey @michael-learns, I see you are using Vue - are you using Nuxt too? We have seen a similar problem in Nuxt in previous issues (discussed on Discord) you can read more about it here: https://discord.com/channels/1138230179878154300/1245001501152378890/1247475355967815815

Are you using our usePowerSync() hook by chance? toRaw might be needed.

const powerSync = usePowerSync();

powerSync.value.init();
const l = connector.registerListener({
  initialized: () => {},
  sessionStarted: () => {     
      toRaw(powerSync.value).connect(connector);
  },
});

@michael-learns
Copy link
Author

i'm using Vite.

I'm not quite sure where to place that code.

@Chriztiaan
Copy link
Contributor

Can you provide the snippet where you currently call .connect?

@michael-learns
Copy link
Author

@Chriztiaan I don't. I'm using supabase as my backend and this is how it's setup.

This is in my App.vue

Image

@michael-learns
Copy link
Author

I'm trying option 1 based on the suggested solution in the discord link you provided

But I'm hesitant to proceed with this solution because of the the Caution in the Vue docs for markRaw

Image Image

@Chriztiaan
Copy link
Contributor

I see! So my understanding is that either marking it as raw when creating the plugin, or converting to raw when connecting should be fine. The reason this is required is because Vue uses a Proxy class class for its reactivity which will break when we clone some of the information when passed via Comlink/Workers.

I would recommend

sessionStarted: () => {     
      toRaw(powerSync.value).connect(connector); // this shouldn't be dangerous to you as you don't access the powerSync value passed in here
  },

over doing it on creation of the plugin.

@michael-learns
Copy link
Author

Thanks @Chriztiaan ! The only issue now is what is connector?

@Chriztiaan
Copy link
Contributor

A connector is what we use resolve the credentials and handle the upload of data from the client.
A Supabase connector example can be seen here: https://github.com/powersync-ja/powersync-js/blob/main/demos/vue-supabase-todolist/src/library/powersync/SupabaseConnector.ts
More about that here: https://docs.powersync.com/installation/client-side-setup/integrating-with-your-backend#integrate-with-your-backend

@michael-learns
Copy link
Author

Thanks @Chriztiaan! I got it. How do I use l then?

@Chriztiaan
Copy link
Contributor

I see for our Vue example: https://github.com/powersync-ja/powersync-js/blob/main/demos/vue-supabase-todolist/src/App.vue
That we don't clear the listener, you could probably add an unmount/destroy hook call that calls l.

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

No branches or pull requests

2 participants