Skip to content

feat: container-based lambda function#56

Merged
Perry2004 merged 1 commit intomainfrom
feat/container-based-lambda
Oct 18, 2025
Merged

feat: container-based lambda function#56
Perry2004 merged 1 commit intomainfrom
feat/container-based-lambda

Conversation

@Perry2004
Copy link
Owner

No description provided.

Copilot AI review requested due to automatic review settings October 18, 2025 23:30
@Perry2004 Perry2004 merged commit 9078088 into main Oct 18, 2025
2 checks passed
@Perry2004 Perry2004 deleted the feat/container-based-lambda branch October 18, 2025 23:30
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR migrates from a serverless Lambda function using Sparticuz/Chromium to a container-based Lambda function using native Playwright with Chromium. The changes enable the Lambda to run in a containerized environment with full browser capabilities.

  • Replaced Sparticuz/Chromium with native Playwright Chromium browser
  • Added Docker configuration for container-based Lambda deployment
  • Updated build scripts to use npm instead of yarn and include Playwright installation

Reviewed Changes

Copilot reviewed 7 out of 9 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
scripts/src/main.ts Updated browser launch configuration to use native Playwright Chromium instead of Sparticuz
scripts/src/lambda-handler.ts Renamed handler function from lambdaHandler to handler for Lambda compatibility
scripts/prepare-image-links.sh Switched from yarn to npm and added Playwright Chromium installation
scripts/package.json Removed Sparticuz/Chromium dependency
scripts/build-lambda.sh Added Docker build script for container-based Lambda
scripts/Dockerfile.script Added multi-stage Dockerfile for Lambda container
scripts/.dockerignore Added Docker ignore file to exclude build artifacts
Files not reviewed (1)
  • scripts/package-lock.json: Language not supported

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines +23 to +24
const children = el.querySelectorAll("*");
for (const child of Array.from(children)) {
Copy link

Copilot AI Oct 18, 2025

Choose a reason for hiding this comment

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

[nitpick] The refactoring from Array.from(el.querySelectorAll("*")) to el.querySelectorAll("*") followed by Array.from(children) in the loop is unnecessary and adds complexity. The original pattern was more direct.

Suggested change
const children = el.querySelectorAll("*");
for (const child of Array.from(children)) {
for (const child of el.querySelectorAll("*")) {

Copilot uses AI. Check for mistakes.
},
);
console.log("Page content is ready.");
await page.waitForTimeout(5000);
Copy link

Copilot AI Oct 18, 2025

Choose a reason for hiding this comment

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

Replacing specific selector waiting with a fixed timeout reduces reliability. The original waitForSelector approach was more robust as it waited for actual content to be ready rather than an arbitrary time period.

Suggested change
await page.waitForTimeout(5000);
await page.waitForSelector('img[src^="https://images.pexels.com/photos/"]', { timeout: 15000 });

Copilot uses AI. Check for mistakes.
await page.waitForTimeout(5000);
console.log("New content loaded after clicking Load More.");

await page.waitForTimeout(2000);
Copy link

Copilot AI Oct 18, 2025

Choose a reason for hiding this comment

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

The timeout was reduced from 5000ms to 2000ms after clicking 'Load More'. This shorter timeout may not allow sufficient time for new content to load, potentially causing the scraper to miss images.

Suggested change
await page.waitForTimeout(2000);
await page.waitForTimeout(5000);

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants