docs: prevent write-after-end crash in repl/presentation example - #13890
Draft
Planeshifter wants to merge 1 commit into
Draft
docs: prevent write-after-end crash in repl/presentation example#13890Planeshifter wants to merge 1 commit into
repl/presentation example#13890Planeshifter wants to merge 1 commit into
Conversation
The nightly `random_examples` workflow crashed running this example in CI: `Error: write after end` at `Presentation.show` (lib/main.js), called from the example's `next()` timeout callback. The example drives an automated slide show via a recursive `setTimeout( next, 2000 )` chain. In a non-interactive CI environment, stdin hits EOF almost immediately, so the REPL emits `exit` well before the slide show would naturally finish. The already-scheduled `next()` timeout still fires afterward and calls `pres.next().show()`, which writes to the REPL's output stream after it has already ended, throwing an unhandled error that crashes the process. This commit tracks the pending timeout in a `timer` variable and clears it in the `exit` handler, so no further slide writes are attempted once the REPL has closed, whether via reaching the last slide or via early stdin EOF. Ref: https://github.com/stdlib-js/stdlib/actions/runs/30775007749
Member
Author
|
The "Calculate test coverage for PR packages" failure is unrelated to this change. Generated by Claude Code |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This pull request:
@stdlib/repl/presentationexample (examples/index.js) that was failing the nightlyrandom_examplesCI workflow.Failing run: https://github.com/stdlib-js/stdlib/actions/runs/30775007749 (workflow
random_examples, step "Run JavaScript examples", develop HEAD15f2e10394448024fff2a039f952c7bfce36dee4).Symptom:
Error: write after endthrown fromPresentation.show(lib/main.js:1199), called from the example'snext()timeout callback, crashing the process with exit code 2.Root cause: The example drives an automated slide show via a recursive
setTimeout( next, 2000 )chain. In CI, stdin is non-interactive and hits EOF almost immediately, so the REPL emitsexitwell before the slide show would naturally finish. The already-schedulednext()timeout still fires ~2s later and callspres.next().show(), which writes to the REPL's output stream after it has already ended.Fix: Track the pending timeout in a
timervariable andclearTimeout( timer )in theexithandler, so no further slide writes are attempted once the REPL has closed, whether by reaching the last slide or by early stdin EOF. Single-file change, 6 insertions / 2 deletions, no behavior change on the normal completion path.Related Issues
This pull request has the following related issues:
Questions
No.
Other
Validation:
node --checkpasses on the modified file.repl/presentationhas notest/directory and this example file is not referenced elsewhere in the repo. Style review confirmed the fix matches this file's existing variable-declaration idiom and flagged (non-blocking) that the added comment could be terser, which was trimmed before this PR.make test-javascript/make lint-javascript-filessuite in this environment (nonode_modulesinstalled / no network access fornpm install); relied on manual review plus the three-agent validation above.Commit type: this change is confined entirely to an
examples/index.jsfile, whichdocs/style-guides/git/README.mdclassifies as documentation-only (docs:), even though the underlying motivation is a crash fix.Checklist
AI Assistance
If you answered "yes" above, how did you use AI assistance?
Disclosure
This PR was investigated, written, and validated by an automated Claude Code CI-triage routine, in response to a nightly CI failure. Root cause was identified by tracing the job logs and REPL/Presentation source; the fix was reviewed by three independent Claude Code review passes (correctness, regression scope, style) before being opened here.
@stdlib-js/reviewers
Generated by Claude Code