Skip to content

Commit

Permalink
whattheduck,web: Fix socket cache ttl
Browse files Browse the repository at this point in the history
  • Loading branch information
bperel committed Sep 29, 2024
1 parent d198427 commit c507536
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions packages/socket.io-client-services/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,14 @@ export class SocketClient {
connect();
}
const startTime = Date.now();
const eventConsoleString = `${namespaceName}/${event}(${args.join(", ")})`;
const eventConsoleString = `${namespaceName}/${event}(${JSON.stringify(args)})`;
const debugCall = async (post: boolean = false) => {
const token = await session?.getToken();
return console.debug(
if (event !== 'toJSON') {
console.debug(
`${eventConsoleString} ${post ? `responded in ${Date.now() - startTime}ms` : `called ${token ? "with token" : "without token"}`} at ${new Date().toISOString()}`,
);
}
};
let cacheKey;
if (cache) {
Expand Down Expand Up @@ -169,12 +171,10 @@ export class SocketClient {
await debugCall(true);
if (cache && cacheKey) {
cache.storage.set(cacheKey, data, {
cache: {
ttl:
typeof cache.ttl === "function"
? cache.ttl(event, args)
: cache.ttl,
},
timeout:
typeof cache.ttl === "function"
? cache.ttl(event, args)
: cache.ttl,
});
}
return data;
Expand Down

0 comments on commit c507536

Please sign in to comment.