BETH stack tutorial non-blocking: `pushToTenantDb` returns exit code of 1
Per the title this bit of code is causing a small problem:
The
exitCode
evaluates to 1
and the error
evaluates to undefined
. The tenant db is successfully created in Turso and the unlinkSync
I think is working as well, so I'm not sure what's causing the exit code. Here's the error:
Noticing that that tenant db is indeed successfully getting pushed to Turso I wrapped the call to this function in the organization controller with a try catch and just logged out the error.
I still log the errors, but this pushes the tenant db to Turso and adds the record to the organization
table. It also updates the user
table as it should.16 Replies
Probably related and actually blocking: I just realized I'm not able to connect to the newly created db's.
It seems like somehow the schema isn't getting applied from this command maybe?
Will take a look when I get home feel free to ping me if I forget
no rush, i really think i've narrowed it down to the
pushToTenantDb
function as everything else is getting added to the other tables as expected. it's as if the tenant dbs are getting created but they're not accepting the schema for some reason
here's a link to the code as is in case that helps: https://github.com/trevorfehrman/beth-stackhm
can you try running with the input arg to true to see the drizzlekit stdout
sure lemme try that
hrm i don't see anything new getting logged out
what's weird is that it successfully creates a turso db, which means the command we're passing to the spawned process is executing, at no point does it say it can't find the config file or something, but the db that gets created is in a corrupted state or something somehow
uh
remove the line that unlinks the file
and see if it gets written / what it contains
oh that's a good idea
can you try running the command just manually then
like the
["bunx", "drizzle-kit", "push:sqlite", --config=${tempConfigPath}
],
yep
hm it's hanging
maybe i just need to wait for the drizzle-kit CLI to get updated to take args, i think you mentioned in your video they were working on it 🤔
does the primary dirzzle kit work?
Yes
uh
im a bit stumped then
yeah weird. If I had to guess it's a Bun issue, bun installs the wrong version of a node module based on my architecture
Thanks for trying though : D
One last comment on this:
For reasons unrelated to the problems detailed in this thread I recently reformatted my laptop. This resolved the earlier weirdness I was experiencing with Bun installing the wrong version of a node module for my CPU arch but when it comes to posting tenant dbs I'm still getting the exact same issue as described.
It successfully posts a new tenant db to Turso but there aren't any tables in it and I get the same errors described above.
I think this is a great tutorial and you can totally use it as a guide to make a full stack app with just one db, which is what most apps are going to want to do anyway, I just wanted to leave this here in case anybody runs into the same issue in the future.