Skip to content

Fix search route error catch handler result being discarded#3692

Open
J8118 wants to merge 1 commit intoShopify:mainfrom
J8118:fix/search-catch-discards-result
Open

Fix search route error catch handler result being discarded#3692
J8118 wants to merge 1 commit intoShopify:mainfrom
J8118:fix/search-catch-discards-result

Conversation

@J8118
Copy link
Copy Markdown

@J8118 J8118 commented Apr 10, 2026

Summary

In the skeleton template's search.tsx loader, the .catch() handler on searchPromise returns a fallback value, but this return value is discarded because return await searchPromise on line 33 awaits the original promise, not the one with the catch handler attached. .catch() creates a new promise chain — the original promise still rejects.

If searchPromise rejects, two things happen:

  1. The .catch() handler logs the error and returns a fallback (but this value goes nowhere)
  2. await searchPromise throws, resulting in a 500 error

File changed:

  • templates/skeleton/app/routes/search.tsx (lines 28-33)

Before:

searchPromise.catch((error: Error) => {
  console.error(error);
  return {term: '', result: null, error: error.message};
});

return await searchPromise;

After:

return await searchPromise.catch((error: Error) => {
  console.error(error);
  return {term: '', result: null, error: error.message};
});

The .catch() was called on searchPromise but the returned chain was
not used. The original promise was awaited separately, so rejections
still threw a 500 error. Now awaiting the promise with the catch
handler so the fallback value is actually returned.
@J8118 J8118 requested a review from a team as a code owner April 10, 2026 09:06
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