Skip to content

The load's abort checks: one step instead of 22 by hand - #328

Merged
alekswebnet merged 1 commit into
mainfrom
fix/load-abort-steps
Dec 3, 2026
Merged

alekswebnet merged 1 commit into
mainfrom
fix/load-abort-steps

Conversation

@alekswebnet

@alekswebnet alekswebnet commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

Closes #327.

  • src/abortable.ts: abortable(signal) returns a step(value), written step(await …), that hands the awaited value on, or throws the signal's reason once the load is aborted. Every await in startLoad, downloadAndIndex, index, supplyParts and supplyLibraries is written that way.
  • 22 signal.aborted checks become 7, each one deciding something: a catch that stops retrying once aborted, startLoad's silence for a replaced load, and the tryBoot guard.
  • Fixes two places a replaced load wrote over its successor: supplyParts set internalLibraryBundle, and supplyLibraries' fallback set the state, the held package and internalLibraryBundle, each after an await with no check.
  • design/element.md: new rule Every await of a load is written step(await …).

Changed after my review of the first version

  • Its step(promise) was a promise of its own, awaited as await step(…), so the load resumed one turn after the answer. A new src set in that turn was missed, and the replaced load wrote its state on: the kind of bug this pull request is here to end. The check now runs in the turn the await resumes in, as the hand-placed checks did; a test holds that turn.
  • So a replaced load does not stop "at once", as The load's abort checks: one helper instead of 22 by hand #327 put it. It stops when the step it waits on settles, as on main; the long steps (a download, the warm, the pack's parts) settle on the abort themselves.
  • Five awaits the first version left outside the step are inside it, so the rule is true of the code: both supplyParts calls, supplyLibraries, its probeSource, and partPkgId.

Tests: tests/unit/abortable.test.ts (4); the player's whole suite passes locally (633). Under #326's config the changed files lint clean but for one await-thenable, on if (attempt) step(await attempt): the finding #326 disables on that line. The two conflict there, so after #326 merges I'll rebase this one and keep its comment.


Summary by cubic

Replaces the load path's 22 hand-placed signal.aborted checks with one abortable(signal) helper from src/abortable.ts. Every await in the load now goes through step(promise), which settles as the promise does or rejects with the signal's reason the moment the load is aborted — so nothing after an await runs for a replaced load.

Also fixes two spots where a replaced load wrote over its successor: supplyParts set internalLibraryBundle, and supplyLibraries' fallback set the state, held package, and internalLibraryBundle after an await with no check.

Notes

  • The remaining 7 checks each decide something: a catch that stops retrying once aborted, startLoad's silence for a replaced load, and the tryBoot guard.
  • Adds tests/unit/abortable.test.ts and a rule in design/element.md that every await of a load goes through its step.

Written for commit 349c049. Summary will update on new commits.

View guided diff Turn on auto-fix

abortable(signal) gives each function of a load a step(value), written
step(await …), that throws the abort in the turn the await resumes in,
in place of 22 hand-placed signal.aborted checks. Two were missing:
supplyParts and supplyLibraries' fallback set the bundle and state of
the load that replaced theirs.
@coderabbitai

coderabbitai Bot commented Dec 3, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 59 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

Commits

Reviewing files that changed from the base of the PR and between d4085e2 and 349c049.

Files selected for processing: 4

  • design/element.md
  • packages/player/src/abortable.ts
  • packages/player/src/h5p-offline-player.ts
  • packages/player/tests/unit/abortable.test.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@alekswebnet
alekswebnet merged commit 133a0bf into main Dec 3, 2026
16 checks passed
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.

The load's abort checks: one helper instead of 22 by hand

1 participant