Skip to content

Commit 5375949

Browse files
committed
Fix for inconsistent date format for presence
1 parent d742ba1 commit 5375949

File tree

2 files changed

+9
-16
lines changed

2 files changed

+9
-16
lines changed

apps/webapp/app/routes/engine.v1.dev.presence.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export const loader = createSSELoader({
4141
},
4242
initStream: async ({ send }) => {
4343
// Set initial presence with more context
44-
await redis.setex(presenceKey, env.DEV_PRESENCE_TTL_MS / 1000, Date.now().toString());
44+
await redis.setex(presenceKey, env.DEV_PRESENCE_TTL_MS / 1000, new Date().toISOString());
4545

4646
// Publish presence update
4747
await redis.publish(

apps/webapp/app/routes/resources.orgs.$organizationSlug.projects.$projectParam.env.$envParam.dev.presence.tsx

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -60,21 +60,14 @@ export const loader = createSSELoader({
6060
// Format lastSeen as ISO string if it exists
6161
let lastSeen = null;
6262
if (currentPresenceValue) {
63-
// Check if it's a numeric timestamp
64-
if (!isNaN(Number(currentPresenceValue))) {
65-
// Convert numeric timestamp to ISO string
66-
lastSeen = new Date(parseInt(currentPresenceValue, 10)).toISOString();
67-
} else {
68-
// It's already a string format, make sure it's ISO
69-
try {
70-
lastSeen = new Date(currentPresenceValue).toISOString();
71-
} catch (e) {
72-
// If parsing fails, use current time as fallback
73-
lastSeen = new Date().toISOString();
74-
logger.warn("Failed to parse lastSeen value, using current time", {
75-
originalValue: currentPresenceValue,
76-
});
77-
}
63+
try {
64+
lastSeen = new Date(currentPresenceValue).toISOString();
65+
} catch (e) {
66+
// If parsing fails, use current time as fallback
67+
lastSeen = new Date().toISOString();
68+
logger.warn("Failed to parse lastSeen value, using current time", {
69+
originalValue: currentPresenceValue,
70+
});
7871
}
7972
}
8073

0 commit comments

Comments
 (0)