Skip to content

Commit

Permalink
hash MessageDeduplicationId to avoid invalid values (#139)
Browse files Browse the repository at this point in the history
* hash MessageDeduplicationId to avoid invalid values

* Sync

---------

Co-authored-by: Frank <[email protected]>
  • Loading branch information
mathisobadia and fwang committed Jun 22, 2023
1 parent 45d6731 commit bbd31b3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/tame-papayas-change.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"open-next": patch
---

server: hash message dedup id
5 changes: 4 additions & 1 deletion packages/open-next/src/adapters/server-adapter.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import path from "node:path";
import crypto from "node:crypto";
import type {
APIGatewayProxyEventV2,
APIGatewayProxyEvent,
Expand Down Expand Up @@ -271,10 +272,12 @@ async function revalidateIfRequired(
// your page will need to have a different etag to bypass the deduplication window.
// If data has the same etag during these 5 min dedup window, it will be deduplicated and not revalidated.
try {
const hash = (str: string) => crypto.createHash('md5').update(str).digest('hex')

await sqsClient.send(
new SendMessageCommand({
QueueUrl: REVALIDATION_QUEUE_URL,
MessageDeduplicationId: `${rawPath}-${headers.etag}`,
MessageDeduplicationId: hash(`${rawPath}-${headers.etag}`),
MessageBody: JSON.stringify({ host, url: rawPath }),
MessageGroupId: "revalidate",
})
Expand Down

1 comment on commit bbd31b3

@vercel
Copy link

@vercel vercel bot commented on bbd31b3 Jun 22, 2023

Choose a reason for hiding this comment

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

Successfully deployed to the following URLs:

open-next – ./

open-next.vercel.app
open-next-git-main-sst-dev.vercel.app
open-next-sst-dev.vercel.app

Please sign in to comment.