Zetax
Zetax
Explore posts from servers
DTDrizzle Team
Created by Zetax on 8/25/2024 in #help
Drizzle misses some schema files
No description
2 replies
CDCloudflare Developers
Created by Zetax on 7/26/2024 in #general-help
Durable object websocket close not working
No description
4 replies
CDCloudflare Developers
Created by Zetax on 7/22/2024 in #general-help
Cloudflare pages nextjs project can't run development server
Hey there, I just tried getting started with a new NextJS project with Cloudflare pages by just using this create command: npm create cloudflare@latest my-next-app -- --framework=next But after installing and running the "npm run dev" command in the project directory, I just get this error and the dev server doesn't start:
 finni on FinnPC at …\zero via  master npm run dev

> next dev

*** Received structured exception #0xc0000005: access violation; stack: 7ff9a5cf301f 7ff7f240077b 7ff7f2400843 7ff7f23f447c 7ff7f23f4427 7ff7f1c6e1be 7ff7f1c6e4cf 7ff7f0b316f6 7ff7f0b314da 7ff7f1de665f 7ff7f1ded816 7ff7f1de6b7c 7ff7f1ded816 7ff7f1de44ec 7ff7f0b21541 7ff7f349559f 7ff9ca01257c 7ff9ca64af27
C:\Users\finni\Desktop\zero\node_modules\wrangler\wrangler-dist\cli.js:29765
throw a;
^
MiniflareCoreError [ERR_RUNTIME_FAILURE]: The Workers runtime failed to start. There is likely additional logging output above.
at #assembleAndUpdateConfig (C:\Users\finni\Desktop\zero\node_modules\miniflare\dist\src\index.js:9178:13)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Mutex.runWith (C:\Users\finni\Desktop\zero\node_modules\miniflare\dist\src\index.js:3521:16)
at async #waitForReady (C:\Users\finni\Desktop\zero\node_modules\miniflare\dist\src\index.js:9235:5)
at async Miniflare2._getProxyClient (C:\Users\finni\Desktop\zero\node_modules\miniflare\dist\src\index.js:9359:5)
at async Miniflare2.getBindings (C:\Users\finni\Desktop\zero\node_modules\miniflare\dist\src\index.js:9378:25)
at async getPlatformProxy (C:\Users\finni\Desktop\zero\node_modules\wrangler\wrangler-dist\cli.js:210805:20)
at async setupDevPlatform (C:\Users\finni\Desktop\zero\node_modules\@cloudflare\next-on-pages\dist\next-dev\index.cjs:183:23)
at async file:///C:/Users/finni/Desktop/zero/next.config.mjs:7:3 {
code: 'ERR_RUNTIME_FAILURE',
cause: undefined
}

Node.js v20.9.0
 finni on FinnPC at …\zero via  master npm run dev

> next dev

*** Received structured exception #0xc0000005: access violation; stack: 7ff9a5cf301f 7ff7f240077b 7ff7f2400843 7ff7f23f447c 7ff7f23f4427 7ff7f1c6e1be 7ff7f1c6e4cf 7ff7f0b316f6 7ff7f0b314da 7ff7f1de665f 7ff7f1ded816 7ff7f1de6b7c 7ff7f1ded816 7ff7f1de44ec 7ff7f0b21541 7ff7f349559f 7ff9ca01257c 7ff9ca64af27
C:\Users\finni\Desktop\zero\node_modules\wrangler\wrangler-dist\cli.js:29765
throw a;
^
MiniflareCoreError [ERR_RUNTIME_FAILURE]: The Workers runtime failed to start. There is likely additional logging output above.
at #assembleAndUpdateConfig (C:\Users\finni\Desktop\zero\node_modules\miniflare\dist\src\index.js:9178:13)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Mutex.runWith (C:\Users\finni\Desktop\zero\node_modules\miniflare\dist\src\index.js:3521:16)
at async #waitForReady (C:\Users\finni\Desktop\zero\node_modules\miniflare\dist\src\index.js:9235:5)
at async Miniflare2._getProxyClient (C:\Users\finni\Desktop\zero\node_modules\miniflare\dist\src\index.js:9359:5)
at async Miniflare2.getBindings (C:\Users\finni\Desktop\zero\node_modules\miniflare\dist\src\index.js:9378:25)
at async getPlatformProxy (C:\Users\finni\Desktop\zero\node_modules\wrangler\wrangler-dist\cli.js:210805:20)
at async setupDevPlatform (C:\Users\finni\Desktop\zero\node_modules\@cloudflare\next-on-pages\dist\next-dev\index.cjs:183:23)
at async file:///C:/Users/finni/Desktop/zero/next.config.mjs:7:3 {
code: 'ERR_RUNTIME_FAILURE',
cause: undefined
}

Node.js v20.9.0
3 replies
CDCloudflare Developers
Created by Zetax on 6/9/2024 in #general-help
How do I store websocket connections for later use?
Hey there, I just got started with Durable objects and thought I would be able to use them to store long lived websocket connections, but it seems I was mistaken. It works when I don't put the Connections in storage, but if I don't do that, the list of connected clients disappears after about 30 seconds even if the websocket connection stays active, which breaks my route that checks if the list of clients is empty and sends a mesasge to all of them if it isn't. Edit: After I thought about it for a bit with my sleep deprived brain I noticed that you of course can't store Websocket connections in Durable objects for obvious reasons, but is there any other way to keep the same list of Clients globally and be able to send messages from the worker they are connected to? As this is needed for my program Am I understanding something about Durable objects wrong? I could really need some help 😬 My code: https://gist.github.com/simplyzetax/de4b9f4d3edaa1c30ff7cf6521199c3f
1 replies
CDCloudflare Developers
Created by Zetax on 6/8/2024 in #general-help
Only lower latency with Warp with worker
No description
3 replies
CDCloudflare Developers
Created by Zetax on 2/3/2024 in #general-help
Weirdly long response times
No description
3 replies
CDCloudflare Developers
Created by Zetax on 11/6/2023 in #workers-help
NodeJS compat not working
No description
13 replies
DTDrizzle Team
Created by Zetax on 7/17/2023 in #help
Updating jsonb objects with Drizzle?
Hey there, i'm currently working on migrating my database and code from MongoDB with Mongoose to Postgres with Drizzle and have encountered a question that I couldnt find answered on the docs. I query JSON like this in my MongoDB database
Profiles.findOneAndUpdate({ accountId: user.accountId }, { $set: { "profiles.athena.items": allItems.items } }, { new: true }, (err, doc) => {
if (err) console.log(err);

}).lean();
Profiles.findOneAndUpdate({ accountId: user.accountId }, { $set: { "profiles.athena.items": allItems.items } }, { new: true }, (err, doc) => {
if (err) console.log(err);

}).lean();
Which updates the profiles.athena.items object in my database, now instead of having one big profiles blob, I created seperate columns for each profile in my drizzle schema and database. These are:
export const profiles = pgTable(
"profiles",
{
id: serial("id").primaryKey(),
created: timestamp("created"),
accountId: varchar("accountId", { length: 256 }),
athena: jsonb("athena"),
campaign: jsonb("campaign"),
collectionBookPeople: jsonb("collection_book_people"),
collectionBookSchematics: jsonb("collection_book_schematics"),
collections: jsonb("collections"),
commonCore: jsonb("common_core"),
commonPublic: jsonb("common_public"),
creative: jsonb("creative"),
metadata: jsonb("metadata"),
outpost: jsonb("outpost"),
profilezero: jsonb("profilezero"),
theater: jsonb("theater"),
},
(table) => {
return {
accountIdIdx: index("account_id_idx").on(table.accountId),
};
},
);
export const profiles = pgTable(
"profiles",
{
id: serial("id").primaryKey(),
created: timestamp("created"),
accountId: varchar("accountId", { length: 256 }),
athena: jsonb("athena"),
campaign: jsonb("campaign"),
collectionBookPeople: jsonb("collection_book_people"),
collectionBookSchematics: jsonb("collection_book_schematics"),
collections: jsonb("collections"),
commonCore: jsonb("common_core"),
commonPublic: jsonb("common_public"),
creative: jsonb("creative"),
metadata: jsonb("metadata"),
outpost: jsonb("outpost"),
profilezero: jsonb("profilezero"),
theater: jsonb("theater"),
},
(table) => {
return {
accountIdIdx: index("account_id_idx").on(table.accountId),
};
},
);
As I'm very new to drizzle and SQL in general, I'm not really sure how to approach querying this now. With MongoDB it was just a single findOneAndUpdate query, but in Drizzle i'm not sure how I can update just a single object inside my JSONB data. Could anyone give me an idea for how this could be done?
2 replies