Skip to content

fix(microbot): treat interrupted waits as cancellation, not errors - #1913

Open
chsami wants to merge 1 commit into
developmentfrom
claude/e15-client-thread-interrupt
Open

chsami wants to merge 1 commit into
developmentfrom
claude/e15-client-thread-interrupt

Conversation

@chsami

@chsami chsami commented Oct 8, 2026

Copy link
Copy Markdown
Owner

Problem

Script error telemetry (client 2.6.30) cluster E15: 18 groups / 76 reports / ~1894 occurrences of java.lang.InterruptedException (groups 121, 43, 206, 26, 207, 156, 67, 200, 205, 242, 323, 148, 170, 177, 315, ...).

  • From CompletableFuture.get in ClientThread.invoke(Supplier) (callers Rs2ActorModel.getWorldLocation, Rs2Tile.runClientRead, AbstractEntityQueryable.nearestOnClientThread, Rs2GameObject.getSceneObjects via Rs2Bank, ...), logged by script catch blocks via Microbot.logStackTrace (messages AttackNpcScript, Rs2Bank, ...) or by third-party/StateMachine loggers.
  • From SwingUtilities.invokeAndWait in Microbot.showMessage ("Error displaying message {}:", VarrockAnvil / JewelleryEnchant).

Root cause

A script thread is interrupted when the script stops (scheduledFuture.cancel(true)) while blocked waiting on the client thread or the EDT. ClientThread.invoke already restores the interrupt flag and rethrows RuntimeException("Interrupted waiting for client thread", ie); script loops then catch it and log it as ERROR, and ScriptErrorReporter reports the InterruptedException root cause. showMessage caught the interrupt as a generic exception, logged ERROR and lost the interrupt flag.

Change

  • Microbot.log(..., ERROR, ex): if the cause chain contains InterruptedException, log at DEBUG instead of ERROR.
  • Microbot.showMessage (both overloads): catch InterruptedException, restore the interrupt flag, log at DEBUG.
  • ScriptErrorReporter.append: skip events whose root cause is InterruptedException (covers non-Microbot loggers too).
  • ClientThread.invoke is untouched (flag already restored; avoids overlap with fix(client-thread): log client-thread timeouts as rate-limited warning #1912). Interrupt flags are never cleared, so scripts' running/sleep checks still stop the loop.

Validation

./gradlew :client:runUnitTests --tests '*MicrobotLogInterruptTest' --tests '*ScriptErrorReporterTest' -> 13 tests, 0 failures (includes :client:compileJava).

  • New MicrobotLogInterruptTest: interrupted client-thread wait logs DEBUG; other failures still ERROR.
  • New ScriptErrorReporterTest.ignoresInterruptedWaits.

Known gaps

  • Scripts that log with their own logger (not Microbot.log) still emit an ERROR line locally; only telemetry is suppressed for them.
  • No unit test for the showMessage path (would pop a Swing dialog).
  • Touches ScriptErrorReporter/its test, also touched by fix(microbot): error telemetry follow-ups from release review #1902 (different hunks).

🤖 Generated with Claude Code

Scripts interrupted on stop while waiting on the client thread or the EDT
surfaced InterruptedException as ERROR logs and script error telemetry.
Log interruption-caused failures at debug in Microbot.log, restore the
interrupt flag in showMessage, and skip interrupted root causes in
ScriptErrorReporter.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 71240ecf-7ffe-440e-a3e2-a73787337d1b
📥 Commits

Reviewing files that changed from the base of the PR and between 2fef406 and 4cbe7cc.

📒 Files selected for processing (4)
  • runelite-client/src/main/java/net/runelite/client/plugins/microbot/Microbot.java
  • runelite-client/src/main/java/net/runelite/client/plugins/microbot/diagnostics/ScriptErrorReporter.java
  • runelite-client/src/test/java/net/runelite/client/plugins/microbot/MicrobotLogInterruptTest.java
  • runelite-client/src/test/java/net/runelite/client/plugins/microbot/diagnostics/ScriptErrorReporterTest.java

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 0 remain after this review.


Walkthrough

The showMessage overloads now restore interrupt status and log interrupted waits at DEBUG. Microbot.log checks exception cause chains and logs interruptions at DEBUG while retaining ERROR logging for other exceptions. ScriptErrorReporter skips errors whose resolved root cause is an InterruptedException. Tests cover logging levels and exclusion from pending reports.

Priority: ⬇️ Low

Merge Risk: ⚪ Minimal · up to 4cbe7

Script shutdown interruptions are now treated as cancellation instead of errors. The change is small and tested, and no merge-blocking risk remains.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 12 functions across 4 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: treating interrupted waits as cancellation instead of errors in Microbot.
Description check ✅ Passed The description directly explains the interruption problem, root cause, implementation changes, validation, and known gaps.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
  • Autopilot · 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

Comment @coderabbitai help to get the list of available commands.

This branch has not been deployed

No deployments
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.

1 participant