Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions apps/runtime/test/widget-dev-sessions.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1080,17 +1080,19 @@ describe("a widget dev session", () => {
const child = spawn(process.execPath, ["-e", script, root, source], { stdio: "ignore" });
const exited = new Promise((done) => child.on("exit", done));

// A build that runs while no folder is at the path: it fails on the missing files, and the session stays live.
// A rebuild asked for while no folder is at the path waits for it rather than failing on the missing files, and
// answers with the one build made once it is back.
const deadline = Date.now() + 5_000;
while (existsSync(root) && Date.now() < deadline) await new Promise((done) => setTimeout(done, 5));
expect(existsSync(root)).toBe(false);
const during = await call("POST", `/widget-dev/sessions/${started.sessionId}/rebuild`);
expect(during.status).toBe(200);
expect(session(during)).toMatchObject({ status: "live", lastBuild: { ok: false, trigger: "rebuild" }, activation: { state: "active", generation: 1 } });

expect(session(during)).toMatchObject({
status: "live",
lastBuild: { ok: true, trigger: "rebuild", generation: 2 },
activation: { state: "active", generation: 2 },
});
expect(await exited).toBe(0);
const rebuilt = await eventually(started.sessionId, (view) => view.status === "stopped" || (view.activation.state === "active" && view.activation.generation === 2));
expect(rebuilt).toMatchObject({ status: "live", activation: { state: "active", generation: 2 } });
});

it("stops a watched session as watch-failed when its folder cannot be looked at for the time bound, and keeps what runs", async () => {
Expand Down
14 changes: 10 additions & 4 deletions docs/open-interfaces.md
Original file line number Diff line number Diff line change
Expand Up @@ -995,10 +995,16 @@ file id with the ones it started watching; when they differ, the folder was made
the folder now at that path and builds it, as it builds a saved change, and logs the old and new ids.

A folder that is missing when the node looks, because a build deleted it and has not made it again yet, is looked for
again for 2 seconds before the session stops. No build starts meanwhile. A build already running when the folder went,
or a rebuild asked for in those 2 seconds, fails on the missing files and leaves the session live; the folder is built
again once it is back. A build that takes longer than 2 seconds to make the folder again stops the session as
`folder-gone`.
again for 2 seconds before the session stops. No build starts meanwhile, and none is reported as failed: a build
already running when the folder went, a save, or a rebuild asked for in those 2 seconds waits, and the folder is built
once when it is back. A rebuild answers with that build. A build that takes longer than 2 seconds to make the folder
again stops the session as `folder-gone`, and a rebuild that was waiting answers that the folder was missing.

A change the platform reports for a folder inside the package, rather than for a file, does not start a build. Windows
reports one the first time a build lists a folder made a moment ago, and a file added, removed or saved is reported
under its own name. For about a second after a folder made again is watched anew, a build that finds the same files as
the build before it is not reported: macOS can report the writes that made the folder after the watch began. A save
made in that time changes the files, so it is built and reported.

A folder chosen through a link or junction is watched at the real path it led to when the session started. A folder
made again counts only while its path still resolves to that real path. Paths that differ only in case count as the
Expand Down
13 changes: 10 additions & 3 deletions docs/open-interfaces.vi.md
Original file line number Diff line number Diff line change
Expand Up @@ -1002,9 +1002,16 @@ những giá trị lúc bắt đầu theo dõi; khi chúng khác nhau, thư mụ
mục hiện nằm ở đường dẫn đó và dựng nó, giống như khi dựng một thay đổi đã lưu, và ghi id cũ lẫn id mới vào nhật ký.

Một thư mục không có ở đó khi node xem, vì một lần dựng đã xoá nó mà chưa tạo lại, sẽ được tìm lại trong 2 giây trước
khi phiên dừng. Trong lúc đó không có lần dựng mới nào bắt đầu. Một lần dựng đang chạy khi thư mục biến mất, hoặc một
lần dựng lại được yêu cầu trong 2 giây đó, sẽ thất bại vì thiếu tệp và phiên vẫn chạy; thư mục được dựng lại khi nó trở
lại. Một lần dựng cần lâu hơn 2 giây để tạo lại thư mục sẽ làm phiên dừng với lý do `folder-gone`.
khi phiên dừng. Trong lúc đó không có lần dựng mới nào bắt đầu, và không lần dựng nào bị báo là thất bại: một lần dựng
đang chạy khi thư mục biến mất, một lần lưu, hoặc một lần dựng lại được yêu cầu trong 2 giây đó sẽ chờ, và thư mục được
dựng một lần khi nó trở lại. Một lần dựng lại sẽ trả về chính lần dựng đó. Một lần dựng cần lâu hơn 2 giây để tạo lại
thư mục sẽ làm phiên dừng với lý do `folder-gone`, và một lần dựng lại đang chờ sẽ trả lời rằng thư mục đã không còn.

Một thay đổi mà nền tảng báo cho một thư mục bên trong gói, thay vì cho một tệp, không khởi động lần dựng nào. Windows
báo một thay đổi như vậy vào lần đầu một lần dựng liệt kê một thư mục vừa được tạo, còn một tệp được thêm, xoá hay lưu
thì được báo bằng chính tên của nó. Trong khoảng một giây sau khi một thư mục được tạo lại bắt đầu được theo dõi lại,
một lần dựng thấy các tệp giống hệt lần dựng trước sẽ không được báo: macOS có thể báo những lần ghi đã tạo ra thư mục
sau khi việc theo dõi bắt đầu. Một lần lưu trong khoảng đó làm thay đổi tệp, nên vẫn được dựng và được báo.

Một thư mục được chọn qua một liên kết hay junction được theo dõi ở đường dẫn thật mà nó dẫn tới lúc phiên bắt đầu. Một
thư mục được tạo lại chỉ được tính khi đường dẫn của nó vẫn phân giải về đúng đường dẫn thật đó. Trên Windows và macOS,
Expand Down
Loading
Loading