Skip to content
Merged
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
5 changes: 5 additions & 0 deletions .changeset/sour-boxes-jump.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@opennextjs/aws": patch
---

Add additional params to the queue override
2 changes: 1 addition & 1 deletion packages/open-next/src/adapters/logger.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { isOpenNextError } from "utils/error";
import { isOpenNextError } from "utils/error.js";

export function debug(...args: any[]) {
if (globalThis.openNextDebug) {
Expand Down
7 changes: 6 additions & 1 deletion packages/open-next/src/core/routing/cacheInterceptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,12 @@ async function computeCacheControl(
url = `${NextConfig.basePath}${url}`;
}
await globalThis.queue.send({
MessageBody: { host, url },
MessageBody: {
host,
url,
eTag: etag,
lastModified: lastModified ?? Date.now(),
},
MessageDeduplicationId: hash(`${path}-${lastModified}-${etag}`),
MessageGroupId: generateMessageGroupId(path),
});
Expand Down
6 changes: 3 additions & 3 deletions packages/open-next/src/core/routing/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -324,11 +324,11 @@ export async function revalidateIfRequired(

// For some weird cases, lastModified is not set, haven't been able to figure out yet why
// For those cases we add the etag to the deduplication id, it might help
const etag = headers.etag ?? headers.ETag ?? "";
const eTag = `${headers.etag ?? headers.ETag ?? ""}`;

await globalThis.queue.send({
MessageBody: { host, url: revalidateUrl },
MessageDeduplicationId: hash(`${rawPath}-${lastModified}-${etag}`),
MessageBody: { host, url: revalidateUrl, eTag, lastModified },
MessageDeduplicationId: hash(`${rawPath}-${lastModified}-${eTag}`),
MessageGroupId: generateMessageGroupId(rawPath),
});
} catch (e) {
Expand Down
2 changes: 2 additions & 0 deletions packages/open-next/src/types/overrides.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ export interface QueueMessage {
MessageBody: {
host: string;
url: string;
lastModified: number;
eTag: string;
};
MessageGroupId: string;
}
Expand Down
14 changes: 12 additions & 2 deletions packages/tests-unit/tests/core/routing/util.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,12 @@ describe("revalidateIfRequired", () => {
await revalidateIfRequired("localhost", "/path", headers);

expect(sendMock).toHaveBeenCalledWith({
MessageBody: { host: "localhost", url: "/path" },
MessageBody: {
host: "localhost",
url: "/path",
eTag: expect.any(String),
lastModified: expect.any(Number),
},
MessageDeduplicationId: expect.any(String),
MessageGroupId: expect.any(String),
});
Expand All @@ -682,7 +687,12 @@ describe("revalidateIfRequired", () => {
await revalidateIfRequired("localhost", "/path", headers);

expect(sendMock).toHaveBeenCalledWith({
MessageBody: { host: "localhost", url: "/path" },
MessageBody: {
host: "localhost",
url: "/path",
eTag: expect.any(String),
lastModified: expect.any(Number),
},
MessageDeduplicationId: expect.any(String),
MessageGroupId: expect.any(String),
});
Expand Down
Loading