`@effect/ui-kit` (Effect-TS/ui): `onMount` callbacks assume browser DOM nodes and crash-unmount subtrees on non-DOM `Html` hosts
Maintainer thường phản hồi trong vòng 1 ngày
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 25/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- javascript, typescript
Hướng nghiên cứu
Read the reported mount callbacks in packages/ui-kit/src/Dialog.ts:602, ScrollArea.ts:434, and Toast.ts:478, then inspect the other affected files under packages/ui-kit/src/. Start by running the linked reproduction’s pnpm repro:test and reviewing its host helper and tests. Done means the listed primitives mount on a non-DOM Html host without an uncaught TypeError or subtree teardown; a linked open pull request is already addressing this issue.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
What version of Effect is running?
effect:4.1.6@effect/ui&@effect/ui-kit:Effect-TS/uimainat77391ee50ae3d3175d670facbf675e9a819ba6a6
What steps can reproduce the bug?
- Clone the minimal reproduction branch:
git clone -b repros/non-dom-host-uikit-bugs https://github.com/cliffordfajardo/ui.git effect-ui-repro cd effect-ui-repro pnpm install pnpm repro:test - Mount a component using
Dialog,Drawer,ScrollArea, orToastProvideronto a valid non-DOMRenderer.Hostthat renders theHtmlvocabulary (elements: [Html.name]) withrunsMounts: trueand providesHtml.Host,HtmlSubscription.AnimationFrames,HtmlSubscription.MediaQueries, andHtmlSubscription.GlobalEvents(see_helpers/nonDomHtmlHost.tsand01-uikit-mounts-crash-non-dom-host/repro.test.ts).
Minimal sketch:
// Host renders Html vocabulary onto non-DOM objects (e.g. a native host like ns-effect-ui's MasonHost)
const host = makeNonDomHtmlHost({ runsMounts: true })
const container = makeNode("element", "root")
yield* Renderer.mount(DialogHostApp, {}, container, {
fallback: (failure, h) => h.div("CRASHED")
}).pipe(Effect.provideContext(makeNonDomContext(host)))
What is the expected behavior?
Components in @effect/ui-kit should either:
- guard browser-DOM-only operations in their
Mount.make/Mount.makeStreamcallbacks (e.g. checking forownerDocument/defaultView/getRootNodeand gracefully becoming a no-op on non-DOM nodes), or - expose a host capability / DOM-mount contract so custom
Htmlhosts that supportonMountfor app/host mounts do not crash when rendering@effect/ui-kitprimitives.
At minimum, opening a Drawer/Dialog or mounting a ScrollArea/ToastProvider on a non-DOM Html host should not throw an uncaught TypeError and tear down the entire component subtree (including the trigger button and app content).
What do you see instead?
27 modules in packages/ui-kit/src/ unconditionally assume the mounted node is a browser HTMLElement / HTMLDialogElement inside Mount.make / Mount.makeStream. When the mount runs on a non-DOM Html host, it throws synchronously and mountRun.ts invokes Kernel.fail(inst, "mount", failure, ...), tearing down the subtree to its error fallback:
Drawer/Dialog(packages/ui-kit/src/Dialog.ts:602):ERROR: /Repro01DrawerApp/Drawer[]/Dialog[] failed in mount TypeError: Cannot read properties of undefined (reading 'defaultView') at packages/ui-kit/src/Dialog.ts:602:38ScrollArea(packages/ui-kit/src/ScrollArea.ts:434):ERROR: /Repro01ScrollAreaApp/ScrollArea[] failed in mount TypeError: Cannot read properties of undefined (reading 'defaultView') at packages/ui-kit/src/ScrollArea.ts:434:49ToastProvider(packages/ui-kit/src/Toast.ts:478):ERROR: /Repro01ToastApp/ToastProvider[] failed in mount TypeError: node.getRootNode is not a function at packages/ui-kit/src/Toast.ts:478:27
Additional information
Encountered while porting an @effect/ui + @effect/ui-kit web app onto NativeScript via ns-effect-ui's MasonHost (a non-DOM Renderer.Host implementing elements: [Html.name]).
Setting runsMounts: false on the host avoids these crashes, but disables all onMount callbacks globally (including non-DOM host mounts) and exposes gaps where @effect/ui-kit only implements interaction behavior inside mounts (filed separately).
Related downstream tracking issue: https://github.com/nstudio/ns-effect-ui/issues/3
- Ngôn ngữ chính
- TypeScript
- Star
- 16.7k
- Fork
- 808
- Merge trung bình
- 21 giờ 22 phút
- Pull request đã merge (30 ngày)
- 486
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của Effect-TS/effect
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
`@effect/ui-native` (Effect-TS/ui): `kit/VirtualList` `list` part widens `R` to `any`, poisoning enclosing componentsCó thể đã có người làm @effect-bot đã nhận hôm nay. Đang mở
Effect-TS/effect#11097 · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
`@effect/ui-native` (Effect-TS/ui): Controlled `input` rejected-edit restore never calls `host.commit()`Có thể đã có người làm @effect-bot đã nhận hôm nay. Đang mở
Effect-TS/effect#11096 · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của Effect-TS/effect
Issue tương tự
-
check:failed streams:edit
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
iptv-org/iptv#60585 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 67/100
Maintainer thường phản hồi trong vòng 1 ngày
-
[Bug]: Critical path skips a child span that ends exactly when the next one startsCó thể đã có người làm @Piyush4801 đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
jaegertracing/jaeger-ui#4865 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 90/100
anthropics/claude-code#112972 ·
-
Type: Improvement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
Maintainer thường phản hồi trong vòng 1 ngày