Commit ea887d5
feat: block HTTP requests during active rebuilds via WatchLock (#81)
## Summary
- Obtain the shared `WatchLock` from the configured watcher before
spawning the watch thread
- Pass the lock into the HTTP serving loop
- Acquire a read guard per request, after parsing the header, so file
reads cannot race with rebuild writes
- Re-export `WatchLock` and `WatchLockGuard` from `xtask-wasm` so
consumers don't need a direct `xtask-watch` dependency to name the types
- Document why `read_header` is intentionally called before acquiring
the lock (connections are accepted and headers parsed during a build,
reducing response latency once it finishes)
## Why
Without coordination, a browser refresh mid-rebuild could receive
incomplete or inconsistent dist artifacts. Using the shared watcher lock
ensures the dev server only serves files once the current build has
fully written its output.
Closes #80
Requires rustminded/xtask-watch#34
---------
Co-authored-by: Cecile Tonglet <cecile.tonglet@cecton.com>1 parent e9dac76 commit ea887d5
3 files changed
Lines changed: 24 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
38 | | - | |
| 38 | + | |
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
| |||
352 | 353 | | |
353 | 354 | | |
354 | 355 | | |
| 356 | + | |
| 357 | + | |
355 | 358 | | |
356 | 359 | | |
357 | 360 | | |
| |||
373 | 376 | | |
374 | 377 | | |
375 | 378 | | |
376 | | - | |
| 379 | + | |
| 380 | + | |
377 | 381 | | |
378 | 382 | | |
379 | 383 | | |
| |||
385 | 389 | | |
386 | 390 | | |
387 | 391 | | |
388 | | - | |
389 | | - | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
390 | 401 | | |
391 | 402 | | |
392 | 403 | | |
393 | 404 | | |
394 | 405 | | |
395 | 406 | | |
396 | 407 | | |
| 408 | + | |
397 | 409 | | |
398 | 410 | | |
399 | 411 | | |
| |||
428 | 440 | | |
429 | 441 | | |
430 | 442 | | |
| 443 | + | |
431 | 444 | | |
432 | 445 | | |
433 | 446 | | |
| |||
450 | 463 | | |
451 | 464 | | |
452 | 465 | | |
| 466 | + | |
453 | 467 | | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
454 | 472 | | |
| 473 | + | |
455 | 474 | | |
456 | 475 | | |
457 | 476 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
| |||
0 commit comments