You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Every time HMR happens, KEY changes. This means that if set_context is called in a parent layout, all the children layouts will be unable to call get_context because the symbol is different.
This causes a hard-to-track-down error.
This might be impossible to solve outright, but a possible measure could be something like this:
exportfunctiongetContext(key){constcontext_map=get_or_init_context_map('getContext');if(DEV&&typeofkey==='symbol'){for(constexisting_keyofcontext_map.keys()){if(typeofexisting_key!=='symbol')continue;if(key===existing_key)continue;if(existing_key.description===key.description){// Log some kind of warning that two symbols with the same name are being used}}}constresult=/** @type {T} */(context_map.get(key));returnresult;}
Reproduction
REPL - will need to be ran locally because the playground doesn't support HMR.
@Mr-Zero88 I know how symbols work. I'm saying it's unintuitive that changing an unrelated area of your code leads to symbols changing and breaking things, and suggesting a DX improvement.
Uh oh!
There was an error while loading. Please reload this page.
Describe the bug
With the following component:
Every time HMR happens, KEY changes. This means that if
set_context
is called in a parent layout, all the children layouts will be unable to callget_context
because the symbol is different.This causes a hard-to-track-down error.
This might be impossible to solve outright, but a possible measure could be something like this:
Reproduction
REPL - will need to be ran locally because the playground doesn't support HMR.
Logs
System Info
Severity
annoyance
The text was updated successfully, but these errors were encountered: