Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/DO-1610: address prematured completion of recache requests #1299

Merged
merged 5 commits into from
Feb 8, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,10 @@ const queueRecachineUrls = async (urlsToRecache: string[]) => {
Entries: urls.map(generateEntry),
});
});
console.log(`Queuing messages for SQS`, {
urlsToRecache: urlsToRecache[0],
messageEntries: messages[0].input.Entries,
});

console.log(`Sending ${messages.length} recaching message batches`);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Context, SQSEvent, SQSRecord } from "aws-lambda";
import { Context, SQSEvent } from "aws-lambda";
import axios from "axios";

const userAgent = "prerender / Googlebot recaching request";
Expand All @@ -9,13 +9,16 @@ const userAgent = "prerender / Googlebot recaching request";
* @param context - The AWS Lambda context object.
*/
export const handler = async (event: SQSEvent, _context: Context) => {
event.Records.forEach(async (record: SQSRecord) => {
for (const record of event.Records) {
const url = record.body;
console.log(`Fetching ${url} for recaching`);
await axios.get(url, {
const res = await axios.get(url, {
headers: {
"User-Agent": userAgent,
},
});
});
console.log(
`Fetched URL: ${url}, Response Code: ${JSON.stringify(res.status)}`
);
}
};
Loading