Skip to content

fix(loader): keep helpers when an optional stage fails - #201

Merged
ss-o merged 1 commit into
mainfrom
bug-200
Sep 18, 2026
Merged

ss-o merged 1 commit into
mainfrom
bug-200

Conversation

@ss-o

@ss-o ss-o commented Sep 18, 2026

Copy link
Copy Markdown
Member

Closes #200

zzinit removed its helper functions and itself before it checked the status of the completion and zpmod stages, so a failed zmodload zi/zpmod printed "rebuild it with zi module build", returned 1, and left nothing to call afterwards. The comment above the unset and the file header both promised the opposite.

Changes

  • public/zsh/init.zsh: return 1 before the unset -f when either optional stage failed; remove the helpers and return 0 only on success. The zpmod diagnostic now ends with "then run zzinit again", matching the hint the source-stage failure path already gives. The hint stays inside the existing ZI[MUTE_WARNINGS] guard.
  • tests/installers.sh: test_init_keeps_helpers_when_zpmod_fails plants a non-ELF zpmod.so, asserts the first run returns 1 with zzinit still defined and the rebuild hint on stderr, removes the file, and asserts the retry returns 0 and unsets the helpers. On the unmodified loader it fails at first_retryable:1 and the retry returns 127.
  • public/checksum.txt: regenerated with sh public/sh/generate-checksums.sh.

Behavior notes

  • With ZI[MUTE_WARNINGS]=1 and a broken zpmod.so, zzinit now returns 1 silently and leaves the eight helper functions defined, where before they were removed. That is the contract the header already documents (helpers are kept on failure so the user can retry); the retry is cheap because zi.zsh guards re-sourcing with ZI[SOURCED].
  • docs/README.md is unchanged: it does not claim retryability, so the issue's alternative (dropping the claim from the docs) had nothing to drop.

Verification

  • sh ./tests/installers.sh: 21 ok, including the new fixture
  • zsh -f -n public/zsh/init.zsh
  • zsh-lint at the CI-pinned commit 1e8b0a6 with zsh-lint.json: exit 0

zzinit removed its helper functions and itself before checking the
status of the completion and zpmod stages, so a failed zmodload left
the user with a "run `zzinit` again" contract and nothing to call.

Return before the unset when either optional stage failed, remove the
helpers only on success, and extend the zpmod diagnostic with the retry
hint the source-stage failure path already gives. Add a fixture that
plants an unloadable zpmod.so, observes the failed run keeping zzinit
defined, and proves the retry succeeds and cleans up.

Closes #200
Copilot AI balanced review requested due to automatic review settings September 18, 2026 07:05
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Sep 18, 2026 •

Copy link
Copy Markdown

Deploying src with  Cloudflare Pages  Cloudflare Pages

Latest commit: 6685c83
Status: ✅  Deploy successful!
Preview URL: https://8b0007e4.zi-src.pages.dev
Branch Preview URL: https://bug-200.zi-src.pages.dev

View logs

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The focused fix, regression test, and checksum update are consistent and complete.

Pull request overview

Keeps zzinit retryable when optional loader stages fail, aligning behavior with its documented contract.

Changes:

  • Preserve helper functions on optional-stage failure.
  • Improve the zpmod retry diagnostic.
  • Add regression coverage and regenerate the checksum.
File summaries
File Description
tests/installers.sh Tests failure recovery and successful retry.
public/zsh/init.zsh Retains helpers until initialization succeeds.
public/checksum.txt Updates the loader checksum.
Review details
  • Files reviewed: 3/3 changed files
  • Comments generated: 0
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@ss-o
ss-o merged commit d19ae48 into main Sep 18, 2026
10 checks passed
@ss-o
ss-o deleted the bug-200 branch September 18, 2026 07:14
github-actions Bot pushed a commit that referenced this pull request Sep 18, 2026
Co-authored-by: Sal <ss-o@users.noreply.github.com> d19ae48
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.

loader: zzinit removes its helpers even when the optional zpmod stage failed, so the advertised retry is impossible

2 participants