Skip to content

Conversation

@hshiozawa
Copy link

@hshiozawa hshiozawa commented Dec 1, 2025

Summary

This PR resolves the issue described below.

#22417

As documented in the linked issue, images are not displayed in Amazon-embedded content.
This behavior also occurs in the latest version (current HEAD) of Ghost.

Root Cause and Fix

I investigated the problem and confirmed that it can be resolved by introducing metascraper-amazon:

#22417 (comment)

Additional Timeout Issue

Large pages like Amazon sometimes cause fetch requests to time out at the default 2-second limit.
I described this problem in detail here, and extending the timeout resolves it:

#22590 (comment)

--

Please check your PR against these items:

  • I've read and followed the Contributor Guide
  • I've explained my change
  • I've written an automated test to prove my change works

We appreciate your contribution! 🙏


Note

Adds metascraper-amazon to metadata scraping and increases oEmbed page fetch timeout to 10s to improve Amazon link embeds.

  • OEmbed/Metadata fetching:
    • Update core/server/services/oembed/OEmbedService.js:
      • Increase fetchPage request timeout from 2000 to 10000 ms.
      • Include metascraper-amazon in metascraper pipeline for bookmark data extraction.
    • Update core/package.json:

Written by Cursor Bugbot for commit efe4c53. This will update automatically on new commits. Configure here.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 1, 2025

Walkthrough

Added metascraper-amazon v5.45.10 to ghost/core/package.json dependencies. Integrated metascraper-amazon into two metascraper pipelines in ghost/core/core/server/services/oembed/OEmbedService.js (bookmark-related scraping paths). Increased HTTP fetch timeout in fetchPage from 2000 ms to 10000 ms. No changes to function signatures or exported/public types.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Files to inspect:
    • ghost/core/core/server/services/oembed/OEmbedService.js — verify the timeout change and the two pipeline additions are correct and consistent (imports/usage).
    • ghost/core/package.json — confirm dependency entry for metascraper-amazon (version 5.45.10) is correct.
  • Pay attention to import/require statements, duplicated pipeline entries, and any stray typos introduced by the additions.

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Fix amazon link card' directly relates to the main objective of resolving the Amazon embedding issue by adding metascraper-amazon and increasing fetch timeout.
Description check ✅ Passed The description is comprehensive and directly related to the changeset, explaining the root cause, the fix with metascraper-amazon, and the timeout issue resolution.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e58c16b and efe4c53.

📒 Files selected for processing (2)
  • ghost/core/core/server/services/oembed/OEmbedService.js (2 hunks)
  • ghost/core/package.json (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • ghost/core/package.json
  • ghost/core/core/server/services/oembed/OEmbedService.js

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
ghost/core/core/server/services/oembed/OEmbedService.js (1)

180-191: Consider broader impact of raising the default fetch timeout to 10s

Bumping the default timeout from 2s to 10s will slow failure paths for all embeds that go through fetchPage, not just Amazon, which can affect editor responsiveness and worker utilization if third‑party hosts hang or are very slow. The merge order (...options last) still allows callers to override this default, which is good.

It may be worth:

  • Confirming all call sites that care about latency explicitly set a tighter options.timeout, and/or
  • Considering a more targeted longer timeout for known slow domains (e.g. Amazon) instead of globally.
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between dc7b6c7 and e58c16b.

📒 Files selected for processing (2)
  • ghost/core/core/server/services/oembed/OEmbedService.js (2 hunks)
  • ghost/core/package.json (1 hunks)
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2025-08-26T16:47:28.150Z
Learnt from: troyciesco
Repo: TryGhost/Ghost PR: 24749
File: ghost/core/core/server/services/members/SingleUseTokenProvider.js:3-5
Timestamp: 2025-08-26T16:47:28.150Z
Learning: When checking for dependencies in Ghost project, ensure to look directly in the specific package.json files rather than relying only on automated searches, as otplib dependency exists at line 204 in ghost/core/package.json version "12.0.1"

Applied to files:

  • ghost/core/package.json
📚 Learning: 2025-08-12T18:33:15.524Z
Learnt from: cmraible
Repo: TryGhost/Ghost PR: 24658
File: ghost/admin/package.json:3-3
Timestamp: 2025-08-12T18:33:15.524Z
Learning: In Ghost's admin package.json, third-party packages like ember-cli-postcss, ember-exam, and ember-power-select have their own independent versioning schemes that are unrelated to Ghost's version numbers. Version number coincidences between Ghost versions and these packages should not trigger update suggestions.

Applied to files:

  • ghost/core/package.json
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Cursor Bugbot
🔇 Additional comments (2)
ghost/core/core/server/services/oembed/OEmbedService.js (1)

283-296: Amazon metascraper integration looks consistent, but verify behavior on non‑Amazon pages

Adding metascraper-amazon at the top of the rules list is consistent with your existing metascraper usage and should enable richer Amazon image extraction while leaving other sites handled by the generic bundles.

A couple of things to double‑check:

  • That the new plugin doesn’t regress metadata for non‑Amazon URLs (since rule order can influence which values “win”).
  • That metascraper’s additional work on Amazon pages doesn’t introduce noticeable delays beyond what the new 10s timeout already allows.

If your new automated test only covers one Amazon URL, consider adding a second from a different Amazon locale or product type to guard against markup variance.

ghost/core/package.json (1)

185-195: metascraper-amazon dependency addition looks consistent with existing metascraper stack

The new "metascraper-amazon": "5.45.10" entry matches the versions of the other metascraper-* bundles you’re already using, and it’s correctly added to ghost/core/package.json alongside the rest of the server‑side metascraper dependencies. No further manifest changes seem necessary here.

Based on learnings, locating and updating this dependency in ghost/core/package.json is the right place for this change.

@hshiozawa hshiozawa force-pushed the fix-amazon-link-card branch from e58c16b to efe4c53 Compare December 1, 2025 09:05
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.

1 participant