`@effect/ui` (Effect-TS/ui): an open `Drawer` under `Component.provide` fails `ssr()` adoption, because a waiting adoption logs the current model
Maintainer thường phản hồi trong vòng 1 ngày
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- 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ệ
- typescript
- Lĩnh vực
- developer-experience, testing
Hướng nghiên cứu
The report points to packages/ui/src/internal/hydrateRun.ts, especially Waits.mount and Waits.step, and describes a one-line fix. Start by checking the referenced logging paths and the reproduction in packages/ui-kit/test/DrawerAdopt.test.ts. Done means the open Drawer under Component.provide passes the SSR adoption check; an open linked pull request (#615) indicates work is already underway.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Written with Claude Code, from an app we're building on Effect UI.
What version of Effect is running?
| Package | Version |
|---|---|
@effect/ui, @effect/ui-kit (Effect-TS/ui) |
0.0.0 snapshot at 0c871f7, where we hit it. Reproduced on main at 4ac356c |
effect |
4.1.6 |
Filed here, as Effect-TS/ui#593 asks while the code moves. We found no existing issue in either tracker.
What steps can reproduce the bug?
ssr() fails for an open ui-kit Drawer (or Dialog) whose tree sits under Component.provide. That is the documented place for a component's Layers. The same tree passes without the provided ancestor, and it passes when the drawer is closed.
To run it, drop this into Effect-TS/ui at packages/ui-kit/test/DrawerAdopt.test.ts. The popover stub is installed once for the file. With the per-test popovers helper from test/utils/document.ts, some runs fail with showPopover is not a function instead:
// @vitest-environment happy-dom
import { Component, UiSchema } from "@effect/ui"
import { Html } from "@effect/ui/html"
import { ssr } from "@effect/ui/html/testing"
import { TestHost } from "@effect/ui/testing"
import { Drawer } from "@effect/ui-kit"
import { assert, describe, it } from "@effect/vitest"
import { Effect, Layer, Schema } from "effect"
Object.assign(HTMLElement.prototype, { hidePopover() {}, showPopover() {} })
const M = UiSchema.TaggedEnum({ Noop: {} })
const OpenSheet = Html.component({
message: M,
model: Schema.Struct({ open: Schema.Boolean }),
name: "OpenSheet",
props: Schema.Struct({ open: Schema.Boolean })
}).make({
init: ($) => ({ open: $.props.open }),
update: { Noop: ($) => $.model },
view: (h, { open }) =>
h.div.children(
Drawer(h, {
key: "sheet",
props: { open },
view: (drawer) =>
h.div(
drawer.portal(h.dialog)?.children(
drawer.viewport(h.div).children(
drawer.popup(h.div).children(drawer.title(h.h2).children("Hello"))
)
)
)
})
)
})
const Root = Html.component({
message: M,
model: Schema.Struct({ open: Schema.Boolean }),
name: "Root",
props: Schema.Struct({ open: Schema.Boolean })
}).make({
init: ($) => ({ open: $.props.open }),
update: { Noop: ($) => $.model },
view: (h, { open }) => h.main.children(OpenSheet(h, { key: "s", props: { open } }))
})
const run = (app: any, open: boolean) =>
Effect.gen(function*() {
const result = yield* ssr(app, { open })
assert.isTrue(result.adopted.some((path) => path.includes("/OpenSheet[")))
}).pipe(Effect.scoped, Effect.provide(TestHost.layer()))
describe("an open Drawer adopts", () => {
it.effect("closed, plain", () => run(Root, false))
it.effect("open, plain", () => run(Root, true))
it.effect("open, under a provided ancestor", () => run(Component.provide(Root, Layer.empty), true))
})
What is the expected behavior?
All three pass. The client adopts the server's Dialog state, mounted: false. The comment in Ssr.ts#L629 says what the check compares: each instance at its adoption, before any update such as an onMount's.
What do you see instead?
The third case fails, in 5 of 5 runs:
SsrError: Server rendering and hydration disagree:
- /Root/OpenSheet[s]/Drawer[sheet]/Dialog[]: the adopted state encodes to {"mounted":true,"started":false,"nestedOpen":0,"trigger":null,"reason":null,"openMethod":null,"closeMethod":null}, the server's is {"mounted":false,"started":false,"nestedOpen":0,"trigger":null,"reason":null,"openMethod":null,"closeMethod":null}
Additional information
Cause.
- The wait. Under a provided ancestor, adoption waits for the Layer.
Waits.stepparks the draft and logsWaitingwithdraft.model, the server's (hydrateRun.ts#L530-L532). - What changes the model during the wait. The Dialog's mount sends
ShowedPortal(Dialog.ts#L1007), which setsmounted: true. - The wrong log. When the wait ends,
Waits.mountlogsMountedwith the model as it is at that moment,inst.model(hydrateRun.ts#L500), instead of the model at adoption.
Fix. One line in hydrateRun.ts:
- this.log(inst, { ...draft, model: inst.model, props: inst.props })
+ this.log(inst, { ...draft, model: draft.model, props: inst.props })
Results with the fix.
- The test above passed in 10 of 10 runs.
- The full
@effect/uiand@effect/ui-kitsuites still pass: 165 files, 2078 tests, plus 3 that already fail by design.
What we didn't establish.
- A test with no ui-kit (a plain
onMountthat changes the model, underComponent.provide(Root, Layer.empty)) does not fail. So the Dialog's mount timing matters, and we didn't work out exactly why.
Impact, as far as we can tell.
- The live model and the DOM look right, and the sheet works in the browser.
- What's wrong is the
Mountedentry in the message log. That breaksssr()'s adoption check, and DevTools replay, which starts from that entry.
- 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