vendure-ecommerce / storefront-qwik-starter

An e-commerce storefront starter built with Qwik and Vendure
https://qwik-storefront.vendure.io
227 stars 86 forks source link

Accessing undefined in routes/layouts.tsx #141

Closed anthonygregis closed 11 months ago

anthonygregis commented 11 months ago

Issue There is a crashing error in the layout when setting up the AppStore state for a fresh vendure deployment. If there is no list of available country codes the following check still passes as a truthy value is passed, so it ends up accessing a non existent 0 index. Instead should check values is defined and check that length is > 0.

Steps to reproduce

  1. Deploy vendure server / worker with no countries
  2. Deploy qwik starter site pointed at fresh api
  3. Try to access qwik starter site and see error

Proposed Resolution Add an additional check to ensure that the array is not empty before trying to access the first item.

Reference src/routes/layout.tsx (Line 63)

michaelbromley commented 11 months ago

Hi, thanks for the report! Would you be interested in submitting a pull request to fix this?

anthonygregis commented 11 months ago

Yah I just opened a PR with a proposed fix and tagged this issue

gioboa commented 11 months ago

Thanks @anthonygregis 👍