Skip to content

Commit 1dcb829

Browse files
committed
fix: overwrite legacy timestamp
1 parent d7b27bb commit 1dcb829

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

packages/app/server/routes/publish.post.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,16 @@ export default eventHandler(async (event) => {
195195
templatesHtmlMap[template] = new URL(`/template/${uuid}`, origin).href;
196196
}
197197

198-
if (!currentCursor || currentCursor.timestamp < runId) {
198+
const LEGACY_MS_TIMESTAMP_CUTOFF = 1e12;
199+
const isStaleCursor = (cursor: { timestamp?: number } | null) => {
200+
if (!cursor) return true;
201+
const ts = Number(cursor.timestamp);
202+
if (!Number.isFinite(ts)) return true;
203+
if (ts >= LEGACY_MS_TIMESTAMP_CUTOFF) return true;
204+
return ts < runId;
205+
};
206+
207+
if (isStaleCursor(currentCursor)) {
199208
await cursorBucket.setItem(cursorKey, {
200209
sha: workflowData.sha,
201210
timestamp: runId,
@@ -208,7 +217,7 @@ export default eventHandler(async (event) => {
208217
) {
209218
const branchCursorKey = `${baseKey}:${workflowData.headBranch}`;
210219
const branchCursor = await cursorBucket.getItem(branchCursorKey);
211-
if (!branchCursor || branchCursor.timestamp < runId) {
220+
if (isStaleCursor(branchCursor)) {
212221
await cursorBucket.setItem(branchCursorKey, {
213222
sha: workflowData.sha,
214223
timestamp: runId,

0 commit comments

Comments
 (0)