[2.0] A long memo chain overflows the stack in the commit/settle path

Đã đóng
#4,587 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue nà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
22/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
javascript, typescript
Lĩnh vực
frontend

Hướng nghiên cứu

The bug is in the commit and settle walks, including settlePendingSource and the staged-error marking, which recurse once per memo node in the reactive graph. Start by reading those functions in the reactive core and reproducing with a warm-built chain of about 8,000 memos over a rejecting async source. Done means the walks are iterative with an explicit stack and the error surfaces as E:boomA at that depth.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

bug

What happens

A chain of createMemo nodes over an async source, read under <Errored> with isPending, overflows the call stack in the commit/settle path once the chain is long enough.

  • On next, a warm-built chain of about 8,000+ memos surfaces E:Maximum call stack size exceeded as the rendered error, in place of the source's own error.
  • With #4582 (the settle walk also stage-marks chain nodes via stageMark), the walk recurses through chains too. At about 15,000 nodes it silently drops the staged E:boomA frame instead of erroring.

Real apps rarely build chains this deep, but the error should be the source's (boomA), never a stack overflow, and a frame should never be dropped without an error.

Repro shape

  1. Make an async source that rejects with new Error("boomA").
  2. Build a chain of N createMemo nodes, each reading the previous one, after the source has a first value (warm build).
  3. Read the last memo under an Errored boundary, together with isPending(last), in a render effect that records frames.
  4. Trigger the rejecting flight and flush.

With N ≈ 8,000 on next, the recorded error is Maximum call stack size exceeded. Expected: E:boomA.

Likely fix direction

Make the commit/settle walks (including settlePendingSource and the staged-error marking) iterative with an explicit stack, instead of recursing per node.

Found during review of #4582. It doesn't block that PR, because next already fails at a shallower depth.

Ngôn ngữ chính
TypeScript
Star
36.2k
Fork
1.1k
Merge trung bình
10 giờ 10 phút
Pull request đã merge (30 ngày)
505

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của solidjs/solid

Tất cả issue của solidjs/solid

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.