fix(core): a second run() starts a second loop, and a failed init leaks the libraries already initialized

Đang mở
#494 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ó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
69/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
typescript
Lĩnh vực
backend

Hướng nghiên cứu

Start with packages/core/src/application/nanoforge-application.ts, especially the run() and init() locations cited in the issue. Trace how running state and initialized libraries are handled, then inspect the library cleanup and viewport disposal paths. Done means repeated calls are rejected and a failed initialization cleans up already initialized libraries in reverse order before rethrowing.

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

Mô tả

bug packages:core
Which package is this bug report for?

core

Issue description

Nothing checks isRunning, so calling run() twice schedules two loops: each __run executes twice per tick and delta is wrong. init() can also run twice. If library N's __init rejects (missing libecs.wasm, NfEnvValidationException), libraries 0..N-1 are never cleared and the viewport keeps its resize listeners.

Where:

Evidence:

this.appState.setIsRunning(true);
this.schedule(loop, 0);
...
for (const library of this.registry.getOrderedForInit()) {
  await library.__init(initContext);
}

Suggested fix: Throw when run / init is called a second time. On init failure, call __clear on the libraries already initialized (reverse order), dispose the viewport, then rethrow.

Found during a code audit of main at be72076.

Code sample

No response

Versions
  • Engine main at be72076
  • pnpm 12.0.0, Node.js 26, Bun 1.3.14
Issue priority

Medium (should be fixed soon)

I have tested this issue on a development release

be72076

Ngôn ngữ chính
TypeScript
Star
7
Fork
2
Merge trung bình
1 ngày 17 giờ
Pull request đã merge (30 ngày)
17

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 NanoForge-dev/Engine

Tất cả issue của NanoForge-dev/Engine

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.