Skip to content

Page fails to load due to blocking Promise.all on large taxonomy fetches #962

@swastikCommits

Description

@swastikCommits

What

The /products/[barcode]/edit route (and potentially /products/new) shows a blank page, then reloads, and finally displays an error message. The page never successfully renders.

The edit page's function in src/routes/products/[barcode]/edit/+page.ts]uses a single Promise.all() to simultaneously await the product API call and 6 large taxonomy JSON files:

const [productReq, categories, labels, brands, stores, origins, countries] = await Promise.all([
    off.getProductV3(params.barcode, { ... }),
    getTaxo<Category>('categories', fetch),   // ~10+ MB
    getTaxo<Label>('labels', fetch),
    getTaxo<Brand>('brands', fetch),
    getTaxo<Store>('stores', fetch),
    getTaxo<Origin>('origins', fetch),
    getTaxo<Country>('countries', fetch)
]);

Combined with export const ssr = false, this causes:
Blank page -> SSR is disabled, so the server sends an empty HTML shell; Long wait; Error page

Steps to reproduce the behavior:

  1. Run the explorer locally (pnpm run dev)
  2. Navigate to /products/8436006833168/edit (or any valid barcode)
  3. Observe: blank page -> loading -> error

Expected behavior

The edit form should render immediately with product data

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    Status

    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions