`@effect/ui-native` (Effect-TS/ui): `NativeHost` color cache checks `out === undefined`, causing repeated cache misses when `device.color` returns `undefined`
I maintainer di solito rispondono entro 1 giorno
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 25/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Ferma
- Stack tecnologico
- react-native, typescript
- Ambito
- mobile
Direzione di ricerca
Read packages/ui-native/src/NativeHost.ts around lines 205–214 and compare the cache lookup with the reproduction test linked in the issue. Run the reproduction’s pnpm test to confirm repeated calls when device.color returns undefined. Done when repeated uses of the same color invoke device.color once; an open linked pull request already addresses this issue.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
partially generated with help of my ai friend - neon 4.4
Hi effect team,
I was trying out this package and wanted to report some bugs encountered while porting a library to effect native
What version of Effect is running?
effect:4.1.7@effect/ui&@effect/ui-native:Effect-TS/uimainat77391ee50ae3d3175d670facbf675e9a819ba6a6react-native:0.88.1
What steps can reproduce the bug?
- Clone the minimal reproduction repository:
git clone https://github.com/cliffordfajardo/effectui-native-error-reproductions.git cd effectui-native-error-reproductions pnpm install pnpm test - Create a
NativeHostviaNativeHost.make({ ui, rootTag: 1, device })wheredevice.colorreturnsundefinedfor an unparsed string color (matching React Native'sprocessColorbehavior for unsupported/invalid color strings), and apply that same color string to multiple views:
const unparsed = "oklch(0.6204 0.195 253.83)"
for (let i = 0; i < 3; i++) {
const node = host.createElement("view")
host.setProp(node, "backgroundColor", unparsed)
host.insertBefore(root, node, undefined)
}
host.commit?.()
- Observe how many times
device.coloris invoked (see03-nativehost-color-cache-misses-on-undefined/repro.test.ts).
What is the expected behavior?
NativeHost's internal colors map should cache the result of device.color(value) on the first lookup even when the result is undefined, so subsequent nodes using the same string color hit the cache (device.color called 1 time, matching the behavior for resolved colors).
What do you see instead?
packages/ui-native/src/NativeHost.ts:205-214 writes undefined into the cache map, but checks out === undefined to detect a cache miss:
const colors = new Map<string, unknown>()
const color = (value: unknown) => {
if (typeof value !== "string") return processColor(value)
let out = colors.get(value)
if (out === undefined) {
if (colors.size > 255) colors.clear()
colors.set(value, out = processColor(value))
}
return out
}
Because colors.get(value) returns undefined both when the key is absent and when processColor(value) returned undefined, every prop assignment with that string misses the cache and re-runs processColor(value) (3 calls instead of 1 in the repro).
Additional information
Checking if (!colors.has(value)) (or storing a sentinel for undefined) ensures unparsed string colors are cached consistently alongside parsed colors and avoids redundant processColor calls across re-renders/lists.
- Lingua principale
- TypeScript
- Stelle
- 16.7k
- Fork
- 808
- Merge medio
- 21h 22m
- PR unite (30g)
- 486
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di Effect-TS/effect
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
`@effect/ui-native` (Effect-TS/ui): `kit/VirtualList` `list` part widens `R` to `any`, poisoning enclosing componentsForse già presa @effect-bot l’ha presa oggi. Aperta
Effect-TS/effect#11097 · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
`@effect/ui-native` (Effect-TS/ui): Controlled `input` rejected-edit restore never calls `host.commit()`Forse già presa @effect-bot l’ha presa oggi. Aperta
Effect-TS/effect#11096 · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di Effect-TS/effect
Issue simili
-
check:failed streams:edit
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
iptv-org/iptv#60585 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 67/100
I maintainer di solito rispondono entro 1 giorno
-
[Bug]: Critical path skips a child span that ends exactly when the next one startsForse già presa @Piyush4801 l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
jaegertracing/jaeger-ui#4865 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 90/100
anthropics/claude-code#112972 ·
-
Type: Improvement
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
I maintainer di solito rispondono entro 1 giorno