docs: Investigate user experience — try/catch anti-pattern with errexit=false default (issue #156)#157
docs: Investigate user experience — try/catch anti-pattern with errexit=false default (issue #156)#157
Conversation
Adding CLAUDE.md with task information for AI processing. This file will be removed when the task is complete. Issue: #156
…exit=false default Investigates the user experience issue reported in #156, triggered by a silent bug in link-assistant/calculator#79 where try/catch was used to detect non-zero exit codes, but command-stream's errexit=false default meant the catch block was never reached. Changes: - Add comprehensive case study at js/docs/case-studies/issue-156/README.md including timeline, root cause analysis, bash vs command-stream comparison table, configuration API documentation, and proposed solutions - Add Pitfall #7 to js/BEST-PRACTICES.md: try/catch anti-pattern with errexit=false, with correct patterns and link to case study - Add reproducible experiments in experiments/issue-156/: 01-default-behavior.mjs — demonstrates default errexit=false behavior 02-errexit-enabled.mjs — demonstrates shell.errexit(true) configuration 03-bash-comparison.sh — bash set -e comparison reference 04-calculator-bug-repro.mjs — reproduces the exact calculator#78 bug Fixes #156 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This reverts commit 0056361.
🤖 Solution Draft LogThis log file contains the complete execution trace of the AI solution draft process. 💰 Cost estimation:
Now working session is ended, feel free to review and add any feedback on the solution draft. |
🔄 Auto-restart 1/3Detected uncommitted changes from previous run. Starting new session to review and commit them. Uncommitted files: Auto-restart will stop after changes are committed or after 2 more iterations. Please wait until working session will end and give your feedback. |
Add changeset for the try/catch anti-pattern with errexit=false case study. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Auto-fix ESLint errors (string concatenation → template literals, formatting) and Prettier formatting in experiment scripts and case study README. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
🔄 Auto-restart 1/3 LogThis log file contains the complete execution trace of the AI solution draft process. 💰 Cost estimation:
Now working session is ended, feel free to review and add any feedback on the solution draft. |
✅ Ready to mergeThis pull request is now ready to be merged:
Monitored by hive-mind with --auto-restart-until-mergeable flag |
Summary
Investigates issue #156 — a user experience problem triggered by a silent bug in link-assistant/calculator#79.
Root Cause
In the calculator's `scripts/version-and-commit.mjs`, `try/catch` was used to detect non-zero exit codes from `git diff --cached --quiet`. However, `command-stream` defaults to `errexit: false` (equivalent to bash without `set -e`), which means commands never throw on non-zero exit codes by default. The `catch` block was silently never reached, causing the auto-release pipeline to skip version commits on every CI run.
This caused 37 changelog fragments to accumulate without being released — every CI run printed "No changes to commit" and exited successfully, while Cargo.toml and CHANGELOG.md updates were staged but never committed.
Changes
`js/docs/case-studies/issue-156/README.md` — Comprehensive case study with:
`js/BEST-PRACTICES.md` — Added Pitfall Built-in 'which' command returns non-zero exit code for existing commands #7: try/catch anti-pattern with `errexit=false`, with examples of the bug and correct fix patterns
`experiments/issue-156/` — 4 runnable experiment scripts:
`.changeset/issue-156-errexit-false-documentation.md` — Changeset for this documentation update (patch)
Key Finding
Answer to Issue #156 Questions
Does command-stream stop executing on first failure by default? No — it defaults to `errexit: false` (like bash without `set -e`). Commands continue after failures.
Can this be configured? Yes — use `shell.errexit(true)` or `set('e')` to enable throw-on-failure behavior.
Behavior Comparison Table
Test Plan
Fixes #156
🤖 Generated with Claude Code