Skip to content

Conversation

@abrahamvg
Copy link
Contributor

@abrahamvg abrahamvg commented Mar 30, 2025

What

Issue

When searching for a product locally on my machine (products/search?q=<name>) I was getting the following error on my console.

client.js?v=68870e34:329 Uncaught (in promise) Svelte error: each_key_duplicate
Keyed each block has duplicate key `undefined` at indexes 0 and 1
https://svelte.dev/e/each_key_duplicate

	in +page.svelte
	in +layout.svelte
	in root.svelte

While reloading the same search result, the results were not getting populated even though the payload was coming in fine.

This issue was resolved for me by updating the loop that generated the ProductCard skeleton from {#each Array(5) as i (i)} to {#each Array(5) as _, i}. Attaching video as well.

Screenshot

image
https://github.com/user-attachments/assets/01f088be-8832-4bef-a8c4-3089b054f900

Fixes bug(s)

@vercel
Copy link

vercel bot commented Mar 30, 2025

@abrahamvg is attempting to deploy a commit to the openfoodfacts Team on Vercel.

A member of the Team first needs to authorize it.

@abrahamvg abrahamvg changed the title Fix for undefined error in search results loading skeleton Fix : undefined error in search results loading skeleton Mar 30, 2025
@abrahamvg abrahamvg changed the title Fix : undefined error in search results loading skeleton fix: undefined error in search results loading skeleton Mar 30, 2025
@github-project-automation github-project-automation bot moved this from Backlog to In progress in OFF Explorer - Primetime ! Mar 31, 2025
@abrahamvg abrahamvg requested a review from VaiTon March 31, 2025 18:44
@vercel
Copy link

vercel bot commented Mar 31, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
openfoodfacts-explorer ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 3, 2025 0:20am

Copy link
Member

@VaiTon VaiTon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@VaiTon
Copy link
Member

VaiTon commented Mar 31, 2025

@abrahamvg
Copy link
Contributor Author

@VaiTon Can I add a rule to only ignore _ variables ?

Code proposed to add :

{
   rules: {
		  '@typescript-eslint/no-unused-vars': ['error', { 
			varsIgnorePattern: '^_$'
		  }]
	  }
}

@VaiTon
Copy link
Member

VaiTon commented Apr 3, 2025

@abrahamvg please run pnpm format ALWAYS before committing (and set up git hooks!)

https://github.com/openfoodfacts/openfoodfacts-explorer/actions/runs/14235091799/job/39916422630?pr=395

@teolemon
Copy link
Member

teolemon commented Apr 4, 2025

@abrahamvg

[email protected] lint /home/runner/work/openfoodfacts-explorer/openfoodfacts-explorer
prettier --check . && eslint .

Checking formatting...
[warn] eslint.config.mjs
[warn] Code style issues found in the above file. Run Prettier with --write to fix.
 ELIFECYCLE  Command failed with exit code 1.
Error: Process completed with exit code 1.

@abrahamvg
Copy link
Contributor Author

@abrahamvg please run pnpm format ALWAYS before committing (and set up git hooks!)

https://github.com/openfoodfacts/openfoodfacts-explorer/actions/runs/14235091799/job/39916422630?pr=395

image

Appologies for late fix.

@teolemon could you please retrigger the auto-label merge action, once the issue is fixed ?

@VaiTon VaiTon merged commit 90fdd3d into openfoodfacts:main Apr 8, 2025
5 of 8 checks passed
@github-project-automation github-project-automation bot moved this from In progress to Done in OFF Explorer - Primetime ! Apr 8, 2025
@abrahamvg abrahamvg deleted the fix/undefined-key-error branch April 8, 2025 11:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Duplicate key error because both being undefined in search results loading skeleton

3 participants