-
Notifications
You must be signed in to change notification settings - Fork 120
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) TypeError: globalThis.uuid is not a function #750
Comments
I don't know if the two things are related but I tried the same process after updating:
Then:
generating now fails with: alex@pop-os:~/ps$ npm run client:generate
> ps@0.1.0 client:generate
> npm run electric:check && npx electric-sql generate --service http://localhost:5133 --proxy postgresql://prisma:proxy_password@localhost:65432/electric
> ps@0.1.0 electric:check
> node ./check-electric-is-running.js
DATABASE_URL: postgresql://postgres:proxy_password@localhost:65432/ps
Generating Electric client...
Successfully generated Electric client at: ./src/generated/client
Building migrations...
generate command failed: TypeError: Cannot read properties of undefined (reading 'sqliteType') |
Hi @barbalex, i created a fresh project using |
@kevin-dp By the way: I did not run a new |
As this blocks me from developing the app, I am trying to isolate the error. My app builds 40 tables. I have reduced the number of tables to find tables whose client generation causes this error. So far I have found one: https://github.com/barbalex/ps/blob/main/db/migrations/02-accounts.sql#L5 When I only build 01 and 02, this table's As there are other tables causing errors I will keep searching. |
Another failing table is: https://github.com/barbalex/ps/blob/main/db/migrations/39-fields.sql There were two offending fields:
So it seems there is a requirement that all referencing fields need to be named exactly the same as the referenced field. That would make building self-referencing tables impossible (parent-child relationships). |
Now that generating the client works again, I am back to the original error: common.js:1 Uncaught (in promise) TypeError: globalThis.uuid is not a function
at S2 (common.js:1:1069)
at he2._getClientId (process.js:62:2512)
at async he2.start (process.js:1:2461)
at async b10.startProcess (registry.js:1:1763) ...which unfortunately also blocks development of the app. |
Actually I have exactly that in my models: https://github.com/barbalex/ps/blob/main/db/migrations/14-places.sql#L5 And that works? |
concerning I tried:
To be honest I have no idea where common.js is running and thus how to add the uuid function to that environment. uuid is correctly installed by electric itself:
This error occurs on my pop os pc and my MacOS notebook. |
I tried reproducing your error but didn't manage yet. On a fresh Electric app, i created your users and accounts tables (just the tables without the indexes) and electrified them. Then i generated the client without problems. I'm using I also copied all your migrations, applied them all on a fresh electric app, and the client builds without any issues. |
O.k., so I rebuilt my project from a fresh electric app too, and it now works. Sorry for bugging you and thanks for your help! |
So after having lunch I returned to my pc and the issue is back 😢 |
Just to double check that we are talking about the same. What about this other issue:
Does it still happen on your original migrations? I could not reproduce that using the 40 migrations you shared. |
Correct. Sorry for mixing up stuff.
I renamed the fields to make them work. Would you like me to test with the original names? |
Yes if you could test with the original names. The 40 migrations in the repo you shared, are that the original names or the renamed ones? Because those worked for me. |
So I did this:
|
Regarding uuid, @samwillis fixed his issue here 6bbe71a |
How can I test it? (the code needs to be compiled, I couldn't just copy it over) |
O.k., so I converted it from typescript to js and replaced the typescript common.js files code in my node_modules folder. And it works! Thanks you guys so much! |
After nuking the db and rebuilding it, migrating and generating the client, I get this error when starting the app:
I found this code, that seems to cause the issue: https://github.com/electric-sql/electric/blob/main/clients/typescript/src/util/common.ts#L120
But I do not understand what is happening or what I might be doing wrong. Glad to give you more information, if you can point me to what would be helpful.
The text was updated successfully, but these errors were encountered: