# 10-ipc-streams-and-files / app 一个「流式传输工作台」:MessagePort 分块 + ack 背压、200MB 文件流式读取 vs 全量读取、 取消与超时。三个页签分别展示进行中的流、内存对比、取消/超时结果。 ## 运行 ```bash pnpm --filter @tutorial/10-ipc-streams-and-files-app start pnpm --filter @tutorial/10-ipc-streams-and-files-app smoke pnpm --filter @tutorial/10-ipc-streams-and-files-app shots ``` ## smoke 输出 ```json {"evt":"smoke","ok":true,"streamAcked":12,"cancelSent":9,"cancelCode":"CANCELLED", "timeout":"TIMEOUT","largeChunks":200,"wholeChunks":200, "streamDeltaMB":72.8,"wholeDeltaMB":199.9} ``` ## 结构 - `main/`:MessageChannelMain 流、4 条在途的背压、取消、超时、200MB 稀疏文件测量 - `preload/`:转发端口消息、暴露 `startStream/cancelStream/slow/readLarge/readWhole` - `shared/`:选项、消息、ack、文件统计类型与守卫 - `src/`:流式传输 / 200MB 文件 / 取消与超时三个页签 ## testid | testid | 用途 | | --- | --- | | `app-title` | 页面标题 | | `tab-stream` / `tab-file` / `tab-cancel` | 三个页签 | | `start-button` / `cancel-button` | 开始 / 取消 | | `stream-status` / `progress` | 状态与进度条 | | `sent-count` / `acked-count` / `inflight-count` | 发送 / ack / 在途 | | `chunk-list` / `chunk-row` | 最近消息 | | `large-button` / `whole-button` / `file-table` / `file-row` | 200MB 对比 | | `cancel-status` / `cancel-sent` / `cancel-acked` | 取消结果 | | `timeout-button` / `timeout-status` | 超时 | ## 已知限制 - 只在 macOS arm64 验证;ΔRSS 受 GC 与文件缓存影响,只看相对关系。 - 200MB 稀疏文件位于 `os.tmpdir()`,smoke 退出时删除;崩溃残留可手动清理。