antiwork/gumroad · warning · ResponseError

Something went wrong.

Error message

Something went wrong.

What it means

deleteAutocompleteSearch() throws at line 20 when DELETE discover_search_autocomplete_path(data) returns 4xx — removing one entry from the signed-in user's Discover recent searches. The whole data object is passed as route params, so a blank/absent query produces a route the router will not match or the controller rejects; expired sessions (401) and CSRF failures on DELETE also land here. Impact is cosmetic — a suggestion entry — so warning severity.

Source

Thrown at app/javascript/data/discover.ts:20

export type AutocompleteSearchResults = {
  products: {
    name: string;
    url: string;
    seller_name: string | null;
    thumbnail_url: string | null;
  }[];
  recent_searches: string[];
  viewed?: boolean;
};

export async function deleteAutocompleteSearch(data: { query: string }) {
  const response = await request({
    method: "DELETE",
    accept: "json",
    url: Routes.discover_search_autocomplete_path(data),
  });
  if (!response.ok) throw new ResponseError();
}

View on GitHub (pinned to afeacbd394)

Solutions

  1. Trim and require a non-empty query before firing the request
  2. Treat failure as non-fatal: remove the entry locally — the server list reconverges on next page load
  3. If entries keep reappearing, check DevTools: the DELETEs are 401/404, not succeeding
  4. Re-login when every authenticated call on the page fails

Example fix

// before
deleteAutocompleteSearch({ query }).catch(() => {});

// after
if (!query.trim()) return;
setRecentSearches((prev) => prev.filter((q) => q !== query)); // optimistic
deleteAutocompleteSearch({ query: query.trim() }).catch(() => {/* self-heals on next load */});
Defensive patterns

Strategy: fallback

Validate before calling

const q = query.trim();
if (!q) return; // empty query cannot match the route — skip the request entirely

Type guard

const isResponseError = (e: unknown): e is ResponseError => e instanceof ResponseError;

Try / catch

setRecentSearches((prev) => prev.filter((s) => s !== query)); // optimistic update first
deleteAutocompleteSearch({ query: query.trim() }).catch(() => {
  // non-fatal: server history reconverges on next page load
});

Prevention

When it happens

Trigger: query empty or whitespace so route generation fails (404/422); session expired so no recent-search store exists (401); DELETE sent without a valid CSRF token; duplicate deletes racing the first (404).

Common situations: A 'clear' UI firing one DELETE per entry while the user navigates away; test harness without cookies; stale state submitting the empty search box.

Related errors


AI-assisted analysis of antiwork/gumroad@afeacbd394 (2026-08-21). Data as JSON: /api/errors/b68014878d55e7cc. Report an issue: GitHub.