Skip to content

🐛 Featured image: Race condition in Unsplash search causes incorrect results #24584

@niranjan-uma-shankar

Description

@niranjan-uma-shankar

Issue Summary

There's a race condition in the Unsplash search within the featured image section, where results for a partially typed term may appear alongside results for the final term. This typically occurs when the user pauses briefly while typing. For example, pausing after "para" before completing "parachute" can show results for both terms.

Here are a few examples:

1. Search for parachute

parasearch.mp4
  • Paused briefly after typing "parac", then completed "parachute".
  • Results for "parac" appear at the top.
  • Results for "parachute" are appended to the results for "parac".
  • At 00:15, a clean search for "parachute" is triggered to demonstrate how the results for the full term appear when no intermediate search interferes.

2. Search for "leaf"

leafsearch.mp4
  • Paused briefly after typing "le", then continued typing "leaf".
  • Results for "le" appear first; "leaf" results are appended below.
  • At 00:18, a fresh search for "leaf" demonstrates the results for the search term when no intermediate search interferes.

3. Search for Neem

neemsearch.mp4
  • Paused briefly after typing "ne", then continued typing "neem".
  • Results for "ne" appear first; "neem" results are appended below.
  • At 00:10, a fresh search for "neem" demonstrates the results for the search term when no intermediate search interferes.

Summary

Due to debounce timing and network latency, earlier search results may not be cleared before newer ones arrive. As a result, results from previous search terms can persist and later results get appended, leading to a mixed and incorrect result set.

Steps to Reproduce

  1. Go to /posts or /pages and click on "New post" (or "New page").
  2. Click on "Add feature image".
  3. In the Unsplash popup, type a search term with a brief pause (<= 1 second) in the middle of typing the term.
  4. Notice that you'd get unrelated results at the top. Scroll down and you'd see results more closely related to your search term.

Ghost Version

6.0.0-rc.2

Node.js Version

22.13.1

How did you install Ghost?

From source

Database type

SQLite3

Code of Conduct

  • I agree to be friendly and polite to people in this repository

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs:triage[triage] this needs to be triaged by the Ghost team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions