Skip to content

fix(viewer): release sessions on early close, fail fast on dead SW, sync MIME map - #125

Merged
erseco merged 1 commit into
fix/asset-and-zip-hardeningfrom
fix/viewer-lifecycle
Sep 26, 2026
Merged

erseco merged 1 commit into
fix/asset-and-zip-hardeningfrom
fix/viewer-lifecycle

Conversation

@erseco

@erseco erseco commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

Stack 2/5, based on #128.

What

  • Viewer closed while loading: if the viewer unmounts while registerSession is in flight, teardown() runs without the session and the SW keeps the whole package in memory. The viewer now unregisters it once the await returns (this.$.isUnmounted).
  • Service Worker install failure: waitForActive never settled when the worker went redundant. The viewer hung on "Preparing viewer…" and never reached the server fallback. It now rejects.
  • MIME map: the PHP fallback map lacked xhtml xml txt ico m4a m4v oga ogv otf pdf, so in fallback mode those were served as application/octet-stream + nosniff (PDFs, ogv video and otf fonts broke). A PHPUnit parity test now reads src/elpx/asset-map.ts and fails on drift.

New tests/js/service-worker-client.test.ts covers activation and the redundant rejection.

Verification

composer install                 exit 0
npm install                      exit 0
npm run typecheck                exit 0
npm test                         Tests 123 passed (123)
npm run lint                     exit 0
npm run build                    ✓ built
make architecture-check          Architecture records OK — 3 records, 0 changes.
make -n download-editor … typecheck   exit 0
vendor/bin/phpunit               OK (116 tests, 328 assertions)
composer cs:check                Found 0 of 32 files that can be fixed
git diff --check                 clean

…ync MIME map

- If the viewer unmounts while registerSession is in flight, teardown ran
  without the session, leaving up to the whole package in SW memory.
  Unregister it once the await returns.
- waitForActive never settled when the worker went 'redundant', so the
  viewer hung on 'Preparing viewer…' and never tried the server fallback.
- The PHP fallback map lacked xhtml, xml, txt, ico, m4a, m4v, oga, ogv,
  otf and pdf, so those were served as octet-stream + nosniff. A parity
  test now reads asset-map.ts and fails on drift.
@github-actions

Copy link
Copy Markdown
Contributor

Preview this PR in the Nextcloud Playground

Open this PR in the Nextcloud Playground

A fresh Nextcloud boots in your browser with this branch's exelearning app installed and enabled (log in as admin / admin). Two sample .elpx are seeded under exelearning-samples/ in Files — click one to open the viewer.

eXeLearning editor: v4.0.5 (overlaid at boot from the upstream release).

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.79%. Comparing base (b04449b) to head (cb54da0).

Additional details and impacted files
@@                      Coverage Diff                       @@
##             fix/asset-and-zip-hardening     #125   +/-   ##
==============================================================
  Coverage                          93.79%   93.79%           
  Complexity                           152      152           
==============================================================
  Files                                 22       22           
  Lines                                661      661           
  Branches                              54       54           
==============================================================
  Hits                                 620      620           
  Misses                                34       34           
  Partials                               7        7           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@erseco
erseco added this pull request to stack #130 September 26, 2026 06:14
@erseco
erseco merged commit f2a514d into main Sep 26, 2026
16 checks passed
@erseco
erseco deleted the fix/viewer-lifecycle branch September 26, 2026 06:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants