BETH stack tutorial blocked "Sync is not supported in databases opened in file mode."

After creating a Turso db and adding the needed .env variables running bun dev results in the follwing error.
$ concurrently "bun run --hot src/main.ts" "bun run uno:dev" "bun run liveReload"
[1] $ bunx --bun unocss --watch
[2] $ bunx beth-stack
[2] šŸ¦Š Livereload running localhost:3001
[0] 73 | },
[0] 74 | });
[0] 75 | }
[0] 76 |
[0] 77 | sync() {
[0] 78 | databaseSyncSync.call(this.db);
[0] ^
[0] error: Sync is not supported in databases opened in file mode.
[0] at sync (/Users/trevorfehrman/Documents/Code/Personal/beth-app/node_modules/libsql/index.js:78:4)
[0] at /Users/trevorfehrman/Documents/Code/Personal/beth-app/node_modules/@libsql/client/lib-esm/sqlite3.js:93:14
[0] at sync (/Users/trevorfehrman/Documents/Code/Personal/beth-app/node_modules/@libsql/client/lib-esm/sqlite3.js:91:17)
[0] at /Users/trevorfehrman/Documents/Code/Personal/beth-app/src/db/index.ts:23:6
at processTicksAndRejections (:55:76)
[0] 73 | },
[0] 74 | });
[0] 75 | }
[0] 76 |
[0] 77 | sync() {
[0] 78 | databaseSyncSync.call(this.db);
[0] ^
[0] error: Sync is not supported in databases opened in file mode.
[0] at sync (/Users/trevorfehrman/Documents/Code/Personal/beth-app/node_modules/libsql/index.js:78:4)
[0] at /Users/trevorfehrman/Documents/Code/Personal/beth-app/node_modules/@libsql/client/lib-esm/sqlite3.js:93:14
[0] at sync (/Users/trevorfehrman/Documents/Code/Personal/beth-app/node_modules/@libsql/client/lib-esm/sqlite3.js:91:17)
[0] at /Users/trevorfehrman/Documents/Code/Personal/beth-app/src/db/index.ts:23:6
[0] at processTicksAndRejections (:55:76)
[1] unocss v0.55.7
[1] ā— UnoCSS in watch mode...
[1] ā„¹ Watching for changes in src/**/*.{ts,tsx}
$ concurrently "bun run --hot src/main.ts" "bun run uno:dev" "bun run liveReload"
[1] $ bunx --bun unocss --watch
[2] $ bunx beth-stack
[2] šŸ¦Š Livereload running localhost:3001
[0] 73 | },
[0] 74 | });
[0] 75 | }
[0] 76 |
[0] 77 | sync() {
[0] 78 | databaseSyncSync.call(this.db);
[0] ^
[0] error: Sync is not supported in databases opened in file mode.
[0] at sync (/Users/trevorfehrman/Documents/Code/Personal/beth-app/node_modules/libsql/index.js:78:4)
[0] at /Users/trevorfehrman/Documents/Code/Personal/beth-app/node_modules/@libsql/client/lib-esm/sqlite3.js:93:14
[0] at sync (/Users/trevorfehrman/Documents/Code/Personal/beth-app/node_modules/@libsql/client/lib-esm/sqlite3.js:91:17)
[0] at /Users/trevorfehrman/Documents/Code/Personal/beth-app/src/db/index.ts:23:6
at processTicksAndRejections (:55:76)
[0] 73 | },
[0] 74 | });
[0] 75 | }
[0] 76 |
[0] 77 | sync() {
[0] 78 | databaseSyncSync.call(this.db);
[0] ^
[0] error: Sync is not supported in databases opened in file mode.
[0] at sync (/Users/trevorfehrman/Documents/Code/Personal/beth-app/node_modules/libsql/index.js:78:4)
[0] at /Users/trevorfehrman/Documents/Code/Personal/beth-app/node_modules/@libsql/client/lib-esm/sqlite3.js:93:14
[0] at sync (/Users/trevorfehrman/Documents/Code/Personal/beth-app/node_modules/@libsql/client/lib-esm/sqlite3.js:91:17)
[0] at /Users/trevorfehrman/Documents/Code/Personal/beth-app/src/db/index.ts:23:6
[0] at processTicksAndRejections (:55:76)
[1] unocss v0.55.7
[1] ā— UnoCSS in watch mode...
[1] ā„¹ Watching for changes in src/**/*.{ts,tsx}
Nothing is getting served to localhost:3000 but a GET request to localhost:3001 returns a 404 not found <:honk_thonk:753870955234721821> I guess I have 2 questions: 1. Why is this command spinning something up on 3001? I've ensured there's nothing running on 3000. 2. It seems like the problem is in the libsql package within node modules. Not sure if this is related to issue I was having with Bun installing the wrong version of esbuild for my CPU architecture or if that's a coincidence. Once again, appreciate any thoughts anyone might have. Thanks!
25 Replies
whatplan
whatplanā€¢15mo ago
yea I think this one is on me in ./db/index.ts wrap the client.sync in a if (config.env.DATABASE_CONNECTION_TYPE === 'local-replica' lmk if that doesnt fix the 3001 is the live reload server basically main 3000 server (your app) uses bun hot reload to restart on file changes 3001 livereload server doesnt restart on restart the 3000 server says "hey 3001 I restarted" then 3001 fowards that to the browser over websocket and tells it to refresh
Trevor
TrevorOPā€¢15mo ago
oh that's really interesting
whatplan
whatplanā€¢15mo ago
fixed
Trevor
TrevorOPā€¢15mo ago
yeah that if check resolved the error i posted above but the app still doesn't render. it seems like it's not able to find the tables
Error in promise: 4 | code;
[0] 5 | constructor(message, code, cause) {
[0] 6 | if (code !== undefined) {
[0] 7 | message = `${code}: ${message}`;
[0] 8 | }
[0] 9 | super(message, { cause });
[0] ^
[0] LibsqlError: : no such table: tweet
[0] at new LibsqlError (/Users/trevorfehrman/Documents/Code/Personal/beth-app/node_modules/@libsql/client/lib-esm/api.js:9:8)
[0] at mapSqliteError (/Users/trevorfehrman/Documents/Code/Personal/beth-app/node_modules/@libsql/client/lib-esm/sqlite3.js:286:15)
[0] at executeStmt (/Users/trevorfehrman/Documents/Code/Personal/beth-app/node_modules/@libsql/client/lib-esm/sqlite3.js:203:14)
[0] at execute (/Users/trevorfehrman/Documents/Code/Personal/beth-app/node_modules/@libsql/client/lib-esm/sqlite3.js:53:18)
[0] at values (/Users/trevorfehrman/Documents/Code/Personal/beth-app/node_modules/drizzle-orm/libsql/index.mjs:177:50)
[0] at /Users/trevorfehrman/Documents/Code/Personal/beth-app/node_modules/drizzle-orm/libsql/index.mjs:148:27
[0] at all (/Users/trevorfehrman/Documents/Code/Personal/beth-app/node_modules/drizzle-orm/libsql/index.mjs:140:14)
[0] at execute (/Users/trevorfehrman/Documents/Code/Personal/beth-app/node_modules/drizzle-orm/session-afae3551.mjs:1368:20)
[0] at then (/Users/trevorfehrman/Documents/Code/Personal/beth-app/node_modules/drizzle-orm/alias-cf8e03cd.mjs:363:15)
[0] at processTicksAndRejections (:55:76)
[0]
[0] 4 | code;
[0] 5 | constructor(message, code, cause) {
[0] 6 | if (code !== undefined) {
[0] 7 | message = `${code}: ${message}`;
[0] 8 | }
[0] 9 | super(message, { cause });
[0] ^
[0] LibsqlError: : no such table: tweet
[0] at new LibsqlError (/Users/trevorfehrman/Documents/Code/Personal/beth-app/node_modules/@libsql/client/lib-esm/api.js:9:8)
[0] at mapSqliteError (/Users/trevorfehrman/Documents/Code/Personal/beth-app/node_modules/@libsql/client/lib-esm/sqlite3.js:286:15)
[0] at executeStmt (/Users/trevorfehrman/Documents/Code/Personal/beth-app/node_modules/@libsql/client/lib-esm/sqlite3.js:203:14)
[0] at execute (/Users/trevorfehrman/Documents/Code/Personal/beth-app/node_modules/@libsql/client/lib-esm/sqlite3.js:53:18)
[0] at values (/Users/trevorfehrman/Documents/Code/Personal/beth-app/node_modules/drizzle-orm/libsql/index.mjs:177:50)
[0] at /Users/trevorfehrman/Documents/Code/Personal/beth-app/node_modules/drizzle-orm/libsql/index.mjs:148:27
[0] at all (/Users/trevorfehrman/Documents/Code/Personal/beth-app/node_modules/drizzle-orm/libsql/index.mjs:140:14)
[0] at execute (/Users/trevorfehrman/Documents/Code/Personal/beth-app/node_modules/drizzle-orm/session-afae3551.mjs:1368:20)
[0] at then (/Users/trevorfehrman/Documents/Code/Personal/beth-app/node_modules/drizzle-orm/alias-cf8e03cd.mjs:363:15)
[0] at processTicksAndRejections (:55:76)
[0] 1 | (function () {"use strict";
[0] ^
[0] TypeError: ReadableStreamDefaultController is not in a state where it can be closed
[0] at close (:1:20)
[0] at closeNow (/Users/trevorfehrman/Documents/Code/Personal/beth-app/node_modules/beth-stack/src/cache/render.ts:79:4)
[0] at /Users/trevorfehrman/Documents/Code/Personal/beth-app/node_modules/beth-stack/src/jsx/render.ts:49:10
[0] at processTicksAndRejections (:55:76)
^C
Error in promise: 4 | code;
[0] 5 | constructor(message, code, cause) {
[0] 6 | if (code !== undefined) {
[0] 7 | message = `${code}: ${message}`;
[0] 8 | }
[0] 9 | super(message, { cause });
[0] ^
[0] LibsqlError: : no such table: tweet
[0] at new LibsqlError (/Users/trevorfehrman/Documents/Code/Personal/beth-app/node_modules/@libsql/client/lib-esm/api.js:9:8)
[0] at mapSqliteError (/Users/trevorfehrman/Documents/Code/Personal/beth-app/node_modules/@libsql/client/lib-esm/sqlite3.js:286:15)
[0] at executeStmt (/Users/trevorfehrman/Documents/Code/Personal/beth-app/node_modules/@libsql/client/lib-esm/sqlite3.js:203:14)
[0] at execute (/Users/trevorfehrman/Documents/Code/Personal/beth-app/node_modules/@libsql/client/lib-esm/sqlite3.js:53:18)
[0] at values (/Users/trevorfehrman/Documents/Code/Personal/beth-app/node_modules/drizzle-orm/libsql/index.mjs:177:50)
[0] at /Users/trevorfehrman/Documents/Code/Personal/beth-app/node_modules/drizzle-orm/libsql/index.mjs:148:27
[0] at all (/Users/trevorfehrman/Documents/Code/Personal/beth-app/node_modules/drizzle-orm/libsql/index.mjs:140:14)
[0] at execute (/Users/trevorfehrman/Documents/Code/Personal/beth-app/node_modules/drizzle-orm/session-afae3551.mjs:1368:20)
[0] at then (/Users/trevorfehrman/Documents/Code/Personal/beth-app/node_modules/drizzle-orm/alias-cf8e03cd.mjs:363:15)
[0] at processTicksAndRejections (:55:76)
[0]
[0] 4 | code;
[0] 5 | constructor(message, code, cause) {
[0] 6 | if (code !== undefined) {
[0] 7 | message = `${code}: ${message}`;
[0] 8 | }
[0] 9 | super(message, { cause });
[0] ^
[0] LibsqlError: : no such table: tweet
[0] at new LibsqlError (/Users/trevorfehrman/Documents/Code/Personal/beth-app/node_modules/@libsql/client/lib-esm/api.js:9:8)
[0] at mapSqliteError (/Users/trevorfehrman/Documents/Code/Personal/beth-app/node_modules/@libsql/client/lib-esm/sqlite3.js:286:15)
[0] at executeStmt (/Users/trevorfehrman/Documents/Code/Personal/beth-app/node_modules/@libsql/client/lib-esm/sqlite3.js:203:14)
[0] at execute (/Users/trevorfehrman/Documents/Code/Personal/beth-app/node_modules/@libsql/client/lib-esm/sqlite3.js:53:18)
[0] at values (/Users/trevorfehrman/Documents/Code/Personal/beth-app/node_modules/drizzle-orm/libsql/index.mjs:177:50)
[0] at /Users/trevorfehrman/Documents/Code/Personal/beth-app/node_modules/drizzle-orm/libsql/index.mjs:148:27
[0] at all (/Users/trevorfehrman/Documents/Code/Personal/beth-app/node_modules/drizzle-orm/libsql/index.mjs:140:14)
[0] at execute (/Users/trevorfehrman/Documents/Code/Personal/beth-app/node_modules/drizzle-orm/session-afae3551.mjs:1368:20)
[0] at then (/Users/trevorfehrman/Documents/Code/Personal/beth-app/node_modules/drizzle-orm/alias-cf8e03cd.mjs:363:15)
[0] at processTicksAndRejections (:55:76)
[0] 1 | (function () {"use strict";
[0] ^
[0] TypeError: ReadableStreamDefaultController is not in a state where it can be closed
[0] at close (:1:20)
[0] at closeNow (/Users/trevorfehrman/Documents/Code/Personal/beth-app/node_modules/beth-stack/src/cache/render.ts:79:4)
[0] at /Users/trevorfehrman/Documents/Code/Personal/beth-app/node_modules/beth-stack/src/jsx/render.ts:49:10
[0] at processTicksAndRejections (:55:76)
^C
Trevor
TrevorOPā€¢15mo ago
that's WoT is kinda hard to read, maybe screenshot is easier
No description
Trevor
TrevorOPā€¢15mo ago
bun db:push returns
āÆ bun db:push
$ bunx drizzle-kit push:sqlite
No config path provided, using default path
Reading config file '/Users/trevorfehrman/Documents/Code/Personal/beth-app/drizzle.config.ts'
drizzle-kit: v0.19.13
drizzle-orm: v0.28.6


[i] No changes detected
āÆ bun db:push
$ bunx drizzle-kit push:sqlite
No config path provided, using default path
Reading config file '/Users/trevorfehrman/Documents/Code/Personal/beth-app/drizzle.config.ts'
drizzle-kit: v0.19.13
drizzle-orm: v0.28.6


[i] No changes detected
whatplan
whatplanā€¢15mo ago
uh are you on remote db or local
Trevor
TrevorOPā€¢15mo ago
DATABASE_CONNECTION_TYPE="local" šŸ¤¦ā€ā™‚ļø i'll see myself out
whatplan
whatplanā€¢15mo ago
uh can you use this extension and look at the actual sqlite file https://marketplace.visualstudio.com/items?itemName=qwtel.sqlite-viewer
SQLite Viewer - Visual Studio Marketplace
Extension for Visual Studio Code - SQLite Viewer for VSCode
whatplan
whatplanā€¢15mo ago
like it should still work though
Trevor
TrevorOPā€¢15mo ago
DATABASE_CONNECTION_TYPE="local" -> DATABASE_CONNECTION_TYPE="remote"
whatplan
whatplanā€¢15mo ago
the code really shouldnt care about the type the client api is identical maybe a drizzle kit thing but it gets the local client
Trevor
TrevorOPā€¢15mo ago
changing the env variable to remote like it is in your video fixed it, the app is running now happy to use sqlite viewer and look at the sql file if you like though
whatplan
whatplanā€¢15mo ago
yea I mean are the tables there like drizzle kit push should still push to it
Trevor
TrevorOPā€¢15mo ago
yeah <:honk_thonk:753870955234721821>
Trevor
TrevorOPā€¢15mo ago
No description
Trevor
TrevorOPā€¢15mo ago
yeah they're not there locally
whatplan
whatplanā€¢15mo ago
oh you know why or wait
Trevor
TrevorOPā€¢15mo ago
it could be related to the weird esbuild issue i have, i essnetially have to npm i and bun install to be able to push at all
whatplan
whatplanā€¢15mo ago
yea im stumped
Trevor
TrevorOPā€¢15mo ago
not sure what the connection could possibly be there but both prolbems touch the same part
whatplan
whatplanā€¢15mo ago
I mean that shouldnt matter like the packages should be the same but the app runs fine though at least on remote
Trevor
TrevorOPā€¢15mo ago
No description
Trevor
TrevorOPā€¢15mo ago
i need my node module to look like that to be able to push the drizzle schema yes it appears to run on remote, thanks again Ethan really excited to work through this project
Want results from more Discord servers?
Add your server