Skip to content
This repository was archived by the owner on Jan 28, 2025. It is now read-only.

Fix passing etag arg as last modified header, prefer last modified if present as message deduplication id #2486

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/libs/lambda-at-edge/src/default-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ const handleOriginResponse = async ({
request,
pageS3Path: s3Uri,
eTag: response.headers["etag"]?.[0].value,
lastModified: response.headers["etag"]?.[0].value,
lastModified: response.headers["last-modified"]?.[0].value,
pagePath: staticRoute.page,
queueName: regenerationQueueName
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,9 @@ export const triggerStaticRegeneration = async (
// We only want to trigger the regeneration once for every previous
// update. This will prevent the case where this page is being
// requested again whilst its already started to regenerate.
MessageDeduplicationId:
options.eTag ??
(options.lastModified
? new Date(options.lastModified).getTime().toString()
: new Date().getTime().toString()),
MessageDeduplicationId: options.lastModified
? new Date(options.lastModified).getTime().toString()
: options.eTag ?? new Date().getTime().toString(),
// Only deduplicate based on the object, i.e. we can generate
// different pages in parallel, just not the same one
MessageGroupId: hashedUri
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ describe("triggerStaticRegeneration()", () => {
});

it.each`
lastModified | etag | expected
${"2021-05-05T17:15:04.472Z"} | ${"tag"} | ${"tag"}
${"2021-05-05T17:15:04.472Z"} | ${undefined} | ${"1620234904472"}
lastModified | etag | expected
${"2021-05-05T17:15:04.472Z"} | ${"tag"} | ${"1620234904472"}
${undefined} | ${"tag"} | ${"tag"}
`(
"should throttle send correct parameters to the queue",
async ({ lastModified, etag, expected }) => {
Expand Down