Skip to content

Commit bbd31b3

Browse files
mathisobadiafwang
andauthored
hash MessageDeduplicationId to avoid invalid values (#139)
* hash MessageDeduplicationId to avoid invalid values * Sync --------- Co-authored-by: Frank <[email protected]>
1 parent 45d6731 commit bbd31b3

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

.changeset/tame-papayas-change.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"open-next": patch
3+
---
4+
5+
server: hash message dedup id

packages/open-next/src/adapters/server-adapter.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import path from "node:path";
2+
import crypto from "node:crypto";
23
import type {
34
APIGatewayProxyEventV2,
45
APIGatewayProxyEvent,
@@ -271,10 +272,12 @@ async function revalidateIfRequired(
271272
// your page will need to have a different etag to bypass the deduplication window.
272273
// If data has the same etag during these 5 min dedup window, it will be deduplicated and not revalidated.
273274
try {
275+
const hash = (str: string) => crypto.createHash('md5').update(str).digest('hex')
276+
274277
await sqsClient.send(
275278
new SendMessageCommand({
276279
QueueUrl: REVALIDATION_QUEUE_URL,
277-
MessageDeduplicationId: `${rawPath}-${headers.etag}`,
280+
MessageDeduplicationId: hash(`${rawPath}-${headers.etag}`),
278281
MessageBody: JSON.stringify({ host, url: rawPath }),
279282
MessageGroupId: "revalidate",
280283
})

0 commit comments

Comments
 (0)