fix(web): initialize readers before opening directory outputs #12353

Merged
StoneDC merged 2 commits from upstream-pr/12353 into main 2026-10-29 10:04:25 +00:00
StoneDC commented 2026-10-28 10:31:41 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by StoneDC on 2026-10-28T10:31:41Z.


What

Initialize a non-stream archive reader before opening its destination in DirectoryWriter.add(). If initialization fails, no writable is acquired. Preserve the existing stream handling and cleanup behavior.

Register directory-writer.test.mjs in a dedicated step of the existing path-filtered PR Web tests job, in addition to the release-time tools/test_web.py command. It covers initialization ordering/failure, directory bypass, buffer content and close, read failure, bounded streaming, cancellation and lock release.

Tested

Exact tested head: 0e9dba02ccdea1a4cd2dd58efabbe820ffb03a75; rebased onto current main 785f7b35d9d26fbf09dc52f225b9d36ec83812b6. This is the explicit main snapshot observed for the final sync; subsequent upstream merges are not included in this claim.

Windows: Python 3.14.3, Node 24.14.1, WinLibs GCC 15.2, CMake 4.3.1. WSL Ubuntu 26.04: Python 3.14.4, Node 22.22.1, GCC 15.2, CMake 4.2.3. Exact committed source archives were tested on the native Linux filesystem. All results below are local results at this head.

  • Execute both actual node --test commands extracted from this head's .github/workflows/web-tests.yml: the existing 15 helper cases plus directory-writer.test.mjs pass (16 total, no failures/skips) on both OSes. All six production browser modules pass node --check.
  • Build this exact head's real relinker_web target in WSL with Emscripten 6.0.3, Ninja Release and ANYPS5_BUILD_WASM=ON, then run the complete python3 tools/test_web.py --build BUILD command: passed on Linux and Windows. Windows runs the same WSL-built WASM/JavaScript artifacts under native Windows Node; this is not a Windows-host Emscripten build.
  • The complete command runs the 16 Node cases, real ZIP-library archive-root and Windows-path tests, and actual WASM conversion integration. It uses repository-generated ELF/module fixtures and controlled library/network/filesystem endpoints, not a game dump.
  • Current-main conventions with this complete body, whitespace, Python 3.9 grammar and production script-registration audits pass.

The final heads of #12351 (24fbd54aa5bf5edcdf662c01b50900c23b94b67f) and #12353 (0e9dba02ccdea1a4cd2dd58efabbe820ffb03a75) merge cleanly. Their PR-workflow additions occupy separate steps and both registrations survive the merge; neither PR requires the other first. Previous combined-run evidence belongs to its original snapshot and is not substituted for these exact-head runs.

No local macOS/older-Python runtime, full native system-library build, GPU, PS5 or game execution was performed. The archive boundary fixtures do not establish browser filesystem behavior on a real title. Hosted jobs for this new head will be evaluated after publication and are not counted as local passes.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5048985880 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/12353). Originally posted by [StoneDC](https://github.com/StoneDC) on 2026-10-28T10:31:41Z. --- ### What Initialize a non-stream archive reader before opening its destination in `DirectoryWriter.add()`. If initialization fails, no writable is acquired. Preserve the existing stream handling and cleanup behavior. Register `directory-writer.test.mjs` in a dedicated step of the existing path-filtered PR Web tests job, in addition to the release-time `tools/test_web.py` command. It covers initialization ordering/failure, directory bypass, buffer content and close, read failure, bounded streaming, cancellation and lock release. ### Tested <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> Exact tested head: `0e9dba02ccdea1a4cd2dd58efabbe820ffb03a75`; rebased onto current main `785f7b35d9d26fbf09dc52f225b9d36ec83812b6`. This is the explicit main snapshot observed for the final sync; subsequent upstream merges are not included in this claim. Windows: Python 3.14.3, Node 24.14.1, WinLibs GCC 15.2, CMake 4.3.1. WSL Ubuntu 26.04: Python 3.14.4, Node 22.22.1, GCC 15.2, CMake 4.2.3. Exact committed source archives were tested on the native Linux filesystem. All results below are local results at this head. - Execute both actual `node --test` commands extracted from this head's `.github/workflows/web-tests.yml`: the existing 15 helper cases plus `directory-writer.test.mjs` pass (16 total, no failures/skips) on both OSes. All six production browser modules pass `node --check`. - Build this exact head's real `relinker_web` target in WSL with Emscripten 6.0.3, Ninja Release and `ANYPS5_BUILD_WASM=ON`, then run the complete `python3 tools/test_web.py --build BUILD` command: passed on Linux and Windows. Windows runs the same WSL-built WASM/JavaScript artifacts under native Windows Node; this is not a Windows-host Emscripten build. - The complete command runs the 16 Node cases, real ZIP-library archive-root and Windows-path tests, and actual WASM conversion integration. It uses repository-generated ELF/module fixtures and controlled library/network/filesystem endpoints, not a game dump. - Current-main conventions with this complete body, whitespace, Python 3.9 grammar and production script-registration audits pass. The final heads of #12351 (`24fbd54aa5bf5edcdf662c01b50900c23b94b67f`) and #12353 (`0e9dba02ccdea1a4cd2dd58efabbe820ffb03a75`) merge cleanly. Their PR-workflow additions occupy separate steps and both registrations survive the merge; neither PR requires the other first. Previous combined-run evidence belongs to its original snapshot and is not substituted for these exact-head runs. No local macOS/older-Python runtime, full native system-library build, GPU, PS5 or game execution was performed. The archive boundary fixtures do not establish browser filesystem behavior on a real title. Hosted jobs for this new head will be evaluated after publication and are not counted as local passes. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: <!-- #PR, or none --> none - [x] Fixes: <!-- issue it closes as Fixes #N, or none --> none - [x] Unblocks: <!-- title ID and Game bring-up discussion, e.g. PPSA01325 #3232, or none --> none - [x] GPUs tested: <!-- for AGC, shader recompiler or VideoOut changes: vendor, model, driver and OS of each GPU the GPU tests ran on; otherwise n/a --> n/a - [x] AI-assisted: <!-- yes / no --> yes
MarcZX10 commented 2026-10-28 10:49:43 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-28T10:49:43Z.

Review: APPROVED


Reviewed the resource-ordering change and ran the exact-head directory-writer.test.mjs: 1 test passed, covering init-before-open, no output acquisition after init failure, buffered writes, read/write failures, stream cancellation, and lock release. The Windows relinker and output-directory hosted checks pass; the macOS relinker jobs remain pending. No stream behavior change is introduced by this move.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5681430390 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/12353#pullrequestreview-5681430390). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-28T10:49:43Z. **Review:** APPROVED --- Reviewed the resource-ordering change and ran the exact-head `directory-writer.test.mjs`: 1 test passed, covering init-before-open, no output acquisition after init failure, buffered writes, read/write failures, stream cancellation, and lock release. The Windows relinker and `output-directory` hosted checks pass; the macOS relinker jobs remain pending. No stream behavior change is introduced by this move.
MarcZX10 commented 2026-10-28 10:53:54 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-28T10:53:54Z.

Review: APPROVED


The refreshed conventions check now passes. My exact-head directory-writer test passed, and the hosted Linux/Windows relinker plus output-directory checks pass. macOS relinker jobs remain pending; the review is scoped to the changed initialization/resource-ordering behavior.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5681477963 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/12353#pullrequestreview-5681477963). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-28T10:53:54Z. **Review:** APPROVED --- The refreshed conventions check now passes. My exact-head directory-writer test passed, and the hosted Linux/Windows relinker plus output-directory checks pass. macOS relinker jobs remain pending; the review is scoped to the changed initialization/resource-ordering behavior.
MarcZX10 commented 2026-10-28 11:17:34 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-28T11:17:34Z.

Review: CHANGES_REQUESTED


The exact-head regression test passes locally on Node 20.19.2 (node --experimental-vm-modules --test demo/web/tests/directory-writer.test.mjs: 1 test passed), and the change is otherwise covered by the existing output-directory and relinker checks. I am requesting one CI registration fix before approval: .github/workflows/web-tests.yml runs node --test on app, batch, failure-report, and output-directory tests, but does not include directory-writer.test.mjs. tools/test_web.py runs at release time, so it does not make this test part of pull-request CI. Please add the new test to the workflow command, then I can re-review the refreshed head.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5681757278 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/12353#pullrequestreview-5681757278). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-28T11:17:34Z. **Review:** CHANGES_REQUESTED --- The exact-head regression test passes locally on Node 20.19.2 (`node --experimental-vm-modules --test demo/web/tests/directory-writer.test.mjs`: 1 test passed), and the change is otherwise covered by the existing output-directory and relinker checks. I am requesting one CI registration fix before approval: `.github/workflows/web-tests.yml` runs `node --test` on `app`, `batch`, `failure-report`, and `output-directory` tests, but does not include `directory-writer.test.mjs`. `tools/test_web.py` runs at release time, so it does not make this test part of pull-request CI. Please add the new test to the workflow command, then I can re-review the refreshed head.
MarcZX10 commented 2026-10-28 11:30:50 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-28T11:30:50Z.

Review: COMMENTED


Re-reviewed exact head 89d2266a67a0287e87dfdb490900ab5805873d6a. The new dedicated pull-request workflow step now runs node --test demo/web/tests/directory-writer.test.mjs, resolving the missing-CI blocker. Locally on Node 20.19.2, the existing four-file Web test command passed 15 tests, and the exact new directory-writer workflow command passed 1 test; git diff --check upstream/main...HEAD passed. I have not approved yet while the refreshed hosted checks are queued.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5681910068 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/12353#pullrequestreview-5681910068). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-28T11:30:50Z. **Review:** COMMENTED --- Re-reviewed exact head `89d2266a67a0287e87dfdb490900ab5805873d6a`. The new dedicated pull-request workflow step now runs `node --test demo/web/tests/directory-writer.test.mjs`, resolving the missing-CI blocker. Locally on Node 20.19.2, the existing four-file Web test command passed 15 tests, and the exact new directory-writer workflow command passed 1 test; `git diff --check upstream/main...HEAD` passed. I have not approved yet while the refreshed hosted checks are queued.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!12353
No description provided.