Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/gorgeous-rules-protect.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@thirdweb-dev/service-utils": patch
---

catch cache puts for auth in cf workers
32 changes: 18 additions & 14 deletions packages/service-utils/src/cf-worker/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,20 +59,24 @@ export async function authorizeWorker(
get: async (clientId: string) => serviceConfig.kvStore.get(clientId),
put: (clientId: string, teamAndProjectResponse: TeamAndProjectResponse) =>
serviceConfig.ctx.waitUntil(
serviceConfig.kvStore.put(
clientId,
JSON.stringify({
updatedAt: Date.now(),
teamAndProjectResponse,
} satisfies TeamAndProjectCacheWithPossibleTTL),
{
expirationTtl:
serviceConfig.cacheTtlSeconds &&
serviceConfig.cacheTtlSeconds >= DEFAULT_CACHE_TTL_SECONDS
? serviceConfig.cacheTtlSeconds
: DEFAULT_CACHE_TTL_SECONDS,
},
),
serviceConfig.kvStore
.put(
clientId,
JSON.stringify({
updatedAt: Date.now(),
teamAndProjectResponse,
} satisfies TeamAndProjectCacheWithPossibleTTL),
{
expirationTtl:
serviceConfig.cacheTtlSeconds &&
serviceConfig.cacheTtlSeconds >= DEFAULT_CACHE_TTL_SECONDS
? serviceConfig.cacheTtlSeconds
: DEFAULT_CACHE_TTL_SECONDS,
},
)
.catch((e) => {
console.warn(e);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hm, shouldn't the consumer handle this if they want?

}),
),
cacheTtlSeconds: serviceConfig.cacheTtlSeconds ?? DEFAULT_CACHE_TTL_SECONDS,
});
Expand Down
Loading