Skip to content

CodeEmbed/frame.tsx: p5.sound never loads in iframes + postMessage uses wildcard origin #8639

@avinxshKD

Description

@avinxshKD

Most appropriate sub-area of p5.js?

  • Accessibility
  • Color
  • Core/Environment/Rendering
  • Data
  • DOM
  • Events
  • Image
  • IO
  • Math
  • Typography
  • Utilities
  • p5.strands
  • WebGL
  • DevOps, Build process, Unit testing
  • Internationalization (i18n)
  • Friendly Errors
  • Other (specify if possible)

p5.js version

N/A - website repo issue, not p5.js core

Web browser and version

All browsers

Operating system

all

Issue :
Every time searchTerm changes, SearchProvider:

  1. fetches the entire search index JSON again
  2. flattens it
  3. creates a brand new Fuse instance
  4. runs the search

Typing "createVector" = 13 requests to the same en.json. No debounce,
no abort, no caching. The Fuse index is expensive to build and should
be created once per locale, not per keystroke.

There's also a race condition, no AbortController means a slow response
for "col" can resolve after "color" and overwrite the results.

Should be:

  • fetch + build Fuse once per locale change, store in a ref
  • separate effect just for running fuse.search(searchTerm)
  • debounce the search (~250ms)
  • AbortController on the fetch with cleanup

Easy to reproduce: open /search/, DevTools Network tab, type anything
fast and watch duplicate requests pile up.

File: src/components/SearchProvider/index.tsx

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions