Skip to content

Fix non-blocking jobs losing running operations on insert failure (1.20) - #255

Open
rubensworks wants to merge 1 commit into
master-1.20-ltsfrom
fix-nonblocking-insert-failure-1.20
Open

rubensworks wants to merge 1 commit into
master-1.20-ltsfrom
fix-nonblocking-insert-failure-1.20

Conversation

@rubensworks

Copy link
Copy Markdown
Member

Port of #254 to 1.20. Related to the non-blocking problem described in #252 (comment).

Problem

When a target accepts the recipe inputs in simulation, but refuses part of them for real, consumeAndInsertCrafting called unmarkCraftingJobProcessing. That dropped all pending output entries of the job, including operations that were already running in the machine in non-blocking mode, so their results were no longer claimed. The refused inputs were also put into the storage network instead of back into the job, leaving the job pending forever with a short buffer.

Inputs are simulated one by one, so two equal instances that each fit separately are accepted in simulation while only one fits for real. This happens easily in non-blocking mode, which fills machines up to capacity.

Changes

Same as the 1.21 PR, minus the start tick bookkeeping that only exists on 1.21:

  • Equal instances are stacked when simulating insertion. Real insertion is unchanged.
  • On a real insertion failure, only the failed operation is undone. Other running operations of the job stay tracked.
  • Refused inputs go back into the job's buffer instead of the storage network (new CraftingHelpers.insertCrafting overload with a fallback storage getter; the existing signature is kept).
  • Observers are only unregistered if the failed operation was still pending.

Tests

This branch has no game tests, so the reproduction tests from the 1.21 PR are not included here. They fail without the fix and pass with it on 1.21. On this branch, ./gradlew build passes (172 unit tests).


Generated by Claude Code

When a target accepted recipe inputs in simulation but not for real,
all running operations of the job were forgotten, and the refused
inputs were moved to the storage network. In non-blocking mode, this
made crafting jobs get stuck forever.

Equal inputs are now stacked when simulating, so simulation also fails
when they only fit separately. If the real insertion still fails, only
that operation is undone, and the refused inputs go back to the job.

Related to #252

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01D8EZpiK75euMoLjy5r6suM
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.

2 participants