Comments (18)
I don't know if the two things are related but I tried the same process after updating:
- electric-sql from 0.7.1 to 0.8.1
- @electric-sql/prisma-generator from 1.1.0 to 1.1.1
Then:
npm run backend:down
npm run backend:start
db:migrate
client:generate
generating now fails with:
alex@pop-os:~/ps$ npm run client:generate
> [email protected] client:generate
> npm run electric:check && npx electric-sql generate --service http://localhost:5133 --proxy postgresql://prisma:proxy_password@localhost:65432/electric
> [email protected] 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')
from electric.
I don't know if the two things are related but I tried the same process after updating:
* electric-sql from 0.7.1 to 0.8.1 * @electric-sql/prisma-generator from 1.1.0 to 1.1.1
Then:
1. `npm run backend:down` 2. `npm run backend:start` 3. `db:migrate` 4. `client:generate`
generating now fails with:
alex@pop-os:~/ps$ npm run client:generate > [email protected] client:generate > npm run electric:check && npx electric-sql generate --service http://localhost:5133 --proxy postgresql://prisma:proxy_password@localhost:65432/electric > [email protected] 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 npx create-electric-app@latest
and double checked to have the same versions of electric-sql and the generator that you are using. Everything works fine on my end. Could you share your Postgres schema such that i can try to reproduce the error?
from electric.
@kevin-dp
Here is the schema: https://github.com/barbalex/ps/tree/main/db/migrations
By the way: I did not run a new npx create-electric-app@latest
, just updated.
from electric.
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 owner_user_id
field causes the error. Renaming it to user_id
solves it.
As there are other tables causing errors I will keep searching.
from electric.
Another failing table is: https://github.com/barbalex/ps/blob/main/db/migrations/39-fields.sql
There were two offending fields:
type text DEFAULT NULL REFERENCES field_types(field_type) ON DELETE CASCADE ON UPDATE CASCADE
: had to rename tofield_type
to make it workwidget text DEFAULT NULL REFERENCES widget_types(widget_type) ON DELETE CASCADE ON UPDATE CASCADE
: had to rename towidget_type
to get it work.
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).
from electric.
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.
from electric.
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).
Actually I have exactly that in my models: https://github.com/barbalex/ps/blob/main/db/migrations/14-places.sql#L5
And that works?
from electric.
concerning globalThis.uuid is not a function
I tried:
- changing globalThis in common.js to self/this/global. Nope.
The problem is not globalThis but the missing of the uuid function npm i --save uuid
. Nopenpm i -g uuid
. Nope
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:
alex@pop-os:~/ps$ npm why uuid
[email protected]
node_modules/uuid
uuid@"^9.0.0" from [email protected]
node_modules/electric-sql
electric-sql@"0.8.2" from the root project
This error occurs on my pop os pc and my MacOS notebook.
from electric.
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
owner_user_id
field causes the error. Renaming it touser_id
solves it.As there are other tables causing errors I will keep searching.
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 [email protected]
and @electric-sql/[email protected]
.
I also copied all your migrations, applied them all on a fresh electric app, and the client builds without any issues.
from electric.
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!
from electric.
So after having lunch I returned to my pc and the issue is back 😢
It happens in chrome and firefox.
from electric.
So after having lunch I returned to my pc and the issue is back 😢 It happens in chrome and firefox.
Just to double check that we are talking about the same.
The issue that is back is the uuid function not being found, right?
I believe @samwillis has a fix for this. I'll ask him to give you an update about the status of that fix.
What about this other issue:
generate command failed: TypeError: Cannot read properties of undefined (reading 'sqliteType')
Does it still happen on your original migrations? I could not reproduce that using the 40 migrations you shared.
from electric.
The issue that is back is the uuid function not being found, right?
Correct. Sorry for mixing up stuff.
Does it still happen on your original migrations?
I renamed the fields to make them work. Would you like me to test with the original names?
from electric.
The issue that is back is the uuid function not being found, right?
Correct. Sorry for mixing up stuff.
Does it still happen on your original migrations?
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.
from electric.
So I did this:
- using the up-to-date version of my app
- reverted three fields in the migrations:
- accounts.user_id > accounts.owning_user_id
- fields.field_type > fields.type
- fields.widget_type > fields.widget
- tested: yes fails with
generate command failed: TypeError: Cannot read properties of undefined (reading 'sqliteType')
- created a new branch from it for you to test with: https://github.com/barbalex/ps/tree/type_error_generating_client
from electric.
Regarding uuid, @samwillis fixed his issue here 6bbe71a
Perhaps this solves it for you?
from electric.
How can I test it? (the code needs to be compiled, I couldn't just copy it over)
from electric.
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!
from electric.
Related Issues (20)
- Delayed/Failure to read your writes, lost writes are common HOT 4
- when select where item contains in json array, array_constiains key not recognize, how to filter if json type constains element HOT 2
- Can't load data when phone is offline in Expo app HOT 5
- [BUG] Syntax error CREATE_REPLICATION_SLOT when install electric-sql with docker HOT 8
- MODULE ERROR: Electric.Replication.PostgresConnector HOT 5
- Possible issue in the new ShapeManager code. HOT 3
- SQLite/PGLite not fully compatible with NextJS HOT 4
- Inactive replication slot causing warnings on DO managed Postgres HOT 6
- Demo example with PostGis plugin?? HOT 1
- Error: FOREIGN KEY constraint failed HOT 4
- [rpc] recv: #SatInStartReplicationResp{`Error: Cannot catch up to the server's current state`} HOT 1
- Unable to install electric-sql on MacOS & Node@22 HOT 2
- Zod rejects UUIDs that Postgres deems valid HOT 1
- `(FunctionClauseError) no function clause matching in Electric.Postgres.Extension.SchemaCache.name/1` HOT 7
- too many arguments on function json_object HOT 2
- Issue with ElectricSQL when I try to change the content of an entry in the database HOT 3
- tauri-sqlite example start failed HOT 2
- Secure auth invalid key HOT 6
- Checkout and Linear example not working (client side issue) HOT 1
- Sync service complains about multiple connections from the same client HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from electric.