Lu
Lu
Explore posts from servers
TTCTheo's Typesafe Cult
Created by Lu on 11/22/2024 in #questions
Zustand /w persist + immer, not persisting multi-tenant.
saved should be persisting through different tenants, but it gets cleared every time. It should retrieve the persisted state and update it no? https://pastecord.com/oragaziboh.typescript
2 replies
TtRPC
Created by Lu on 11/19/2024 in #❓-help
Do I need a server to use tRPC?
Since we use RQ at work for our product - I thought might as well bring tRPC into it since it couples things very well. We dont do anything serverless on the frontend, so curious if I need to install an adapter to Vite and spin up a server?
2 replies
DTDrizzle Team
Created by Lu on 6/21/2024 in #help
limiting json_agg
Having a bit of a skill issue limiting the amount of data returned from json_agg
const query = ctx.db
.select({
...groupByFilters,
rowCount: sql<number>`count(${schema.returns.id})`.as(
"row_count",
),
data: sql`json_agg(${schema.returns})`,
})
.from(schema.returns)
.groupBy(...Object.values(groupByFilters))
.limit(limit + 1); // limit the amount of groups returned
const query = ctx.db
.select({
...groupByFilters,
rowCount: sql<number>`count(${schema.returns.id})`.as(
"row_count",
),
data: sql`json_agg(${schema.returns})`,
})
.from(schema.returns)
.groupBy(...Object.values(groupByFilters))
.limit(limit + 1); // limit the amount of groups returned
I tried to add a subquery, but I can't seem to get it right
1 replies
CDCloudflare Developers
Created by Lu on 6/8/2024 in #general-help
Queues + DO's + DB connections
I distribute load to multiple different unique DO's, where each one creates a new connection. I keep getting PostgresError: Max client connections reached. I was under the impression that after DB operations are done, it will automatically close the connection by itself. My thinking is to spawn a unique durable object for insertions, and to keep it alive throughout my distribution process so i can minimize the amount of connections it opens. Any advice?
1 replies
CDCloudflare Developers
Created by Lu on 6/3/2024 in #general-help
Having such a bad experience with Queues & DOs
I have a lot of data to fetch from an external API. I queue up each page which then distributes additional processing via durable objects. It starts out perfectly fine, but once it reaches half of the pages it needs to process, it just hangs. Each page has a unique shared ID to keep durable objects alive for in-memory state. After a page finishes fetching, I dispose the DO. Is there something I am not understanding? (this is all local & using RPC )
1 replies
CDCloudflare Developers
Created by Lu on 6/3/2024 in #workers-help
An RPC result was not disposed properly
I have a DO that returns an object and is marked as Disposable. I keep getting this error, and i'm not entirely sure how to go about it, because I thought it automatically disposes?
An RPC result was not disposed properly. One of the RPC calls you made expects you to call dispose() on the return value, but you didn't do so. You cannot rely on the garbage collector for this because it may take arbitrarily long before actually collecting unreachable objects.
An RPC result was not disposed properly. One of the RPC calls you made expects you to call dispose() on the return value, but you didn't do so. You cannot rely on the garbage collector for this because it may take arbitrarily long before actually collecting unreachable objects.
1 replies
CDCloudflare Developers
Created by Lu on 5/30/2024 in #general-help
Best way to retrieve Queue List within a CF worker?
I know there is a Queue API that you can fetch from a CF worker, but is there another way to do so?
2 replies
CDCloudflare Developers
Created by Lu on 5/26/2024 in #general-help
attach a payload to queue batch rather than each message?
With CF queues, are you able to send a payload that’s attached to the actual batch, rather than each message? I would like to send a userId for example to the controller, rather than to each consumer message.
3 replies
DTDrizzle Team
Created by Lu on 5/23/2024 in #help
Rename conflicted column (postgres)
I am having a bit of trouble getting this to work.
await db
.insert(schema.listings)
.values(listings)
.onConflictDoUpdate({
target: schema.listings.SKU,
set: {
SKU: sql`CONCAT(EXCLUDED.${schema.listings.SKU.name}, '-duplicate')`,
},
});
await db
.insert(schema.listings)
.values(listings)
.onConflictDoUpdate({
target: schema.listings.SKU,
set: {
SKU: sql`CONCAT(EXCLUDED.${schema.listings.SKU.name}, '-duplicate')`,
},
});
Error I get
Uncaught (in promise) PostgresError: syntax error at or near "$601"
Uncaught (in promise) PostgresError: syntax error at or near "$601"
1 replies
CDCloudflare Developers
Created by Lu on 5/21/2024 in #general-help
best approach to apply pollyfills?
A library I want to use within a CF worker imports “crypto”, so I need to apply a pollyfill that will use node:crypto instead. I’ve never messed around with pollyfills so I am not sure how to go about this correctly.
3 replies
TTCTheo's Typesafe Cult
Created by Lu on 5/9/2024 in #questions
TRPC deserialization cuts off long string to client
I got an oauth2 URL that’s very long because scopes are added as search params. The URL returned to the client is cut off completely. Not sure how to go about this. Is this related to superjson somehow?
1 replies
TtRPC
Created by Lu on 5/8/2024 in #❓-help
Mutation returning a long URL is being cut off
I have an authentication URL for an oauth2 provider that returns a long URL due to scopes being added. The server returns a cut-off version of it to the client. Not sure why.
1 replies
CDCloudflare Developers
Created by Lu on 12/14/2023 in #workers-help
How does tiered caching work in the CF worker other than enabling it?
This is what I understand in terms of control Workers have in-memory cache of x mb's, so you can define a memory cache via new Map for example. Workers can use Cache API via caches.default.put Both of these exist locally via colocation, so in-memory cache is going to be fastest, and then colo cache is second fastest in terms of latency for data retrieval.
If your data does not exist in both of those, tiered caching comes into play, and from my understanding its tied to the fetch api. What does this mean exactly? Would love a code example of the breakdown for:
1. check in-memory cache (db response)
2. check local cache (db respoonse)
3. check tiered cache (db response)
4. if non of those have the data needed, it would fetch data from a database (origin)
1. check in-memory cache (db response)
2. check local cache (db respoonse)
3. check tiered cache (db response)
4. if non of those have the data needed, it would fetch data from a database (origin)
14 replies
CDCloudflare Developers
Created by Lu on 8/18/2023 in #general-help
Response headers are showing cloudflare headers
In my worker I am fetching an external API, and ultimately need to read the headers from the response. The problem is that it keeps showing me request headers instead of the response headers.
2 replies
CDCloudflare Developers
Created by Lu on 6/28/2023 in #general-help
Clearing workers cache?
Is there a way to purge the entire cache for a worker from the CF dashboard itself? Or whats a good way to purge.
2 replies
TTCTheo's Typesafe Cult
Created by Lu on 6/2/2023 in #questions
How to redirect with new headers back to the same page?
User goes to page /foo, we check if this page is protected, if it is, we rewrite the page to something else using middleware, now this identical page has a password form. The goal is to authenticate the password, and if its correct, redirect them back to the original page with headers pretty much allowing the user to skip the rewrite in the middleware and view the protected page. Is this possible?
2 replies
TtRPC
Created by Lu on 5/25/2023 in #❓-help
BullMQ + TRPC
Curious how to configure BullMQ with TRPC correctly. Currently I have the queue, queueevents, and the worker inside a router. Though it works, I have a feeling its not the right approach?
4 replies
TtRPC
Created by Lu on 4/10/2023 in #❓-help
Are TRPC server procedures actual endpoints? Meaning can you directly do a `post` request to them?
Lets say you have a public procedure called getHelloWorld, can you hit it by doing localhost:3000/trpc/baseRouter/getHelloWorld? or something
4 replies
TtRPC
Created by Lu on 4/5/2023 in #❓-help
Confused about createProxySSGHelpers
If you can use this helper inside of getServerSideProps without having ssr: true what is the difference when you do enable ssr and forward headers to the server from the client?
1 replies
TtRPC
Created by Lu on 4/5/2023 in #❓-help
How to check if data is being prefetched?
What is a method to check if ssg prefetching actually occurs? Through the network tab?
1 replies