Fix: concurrent tool execution fails with ProcessDriver due to $this capture and circular references#1009
Open
vinitkadam03 wants to merge 1 commit intoprism-php:mainfrom
Conversation
d1f308a to
9c08434
Compare
… circular references in invokable subclasses
9c08434 to
a207a10
Compare
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.
Summary
Fixes #893 — concurrent tool execution via Laravel's
Concurrency::run()fails because closures capture$this(the handler object), causingSerializableClosureto serialize the entire application container. This also fixes the->using($this)circular reference issue for class-based invokable tools.Changes
CallsToolstrait — eliminate$thiscapture in concurrent closuresToolclass — fix circular reference and named argument handlingusing()now detects$fn === $thisand skips the assignment, preventing theTool -> $fn -> Toolcircular reference that breaksSerializableClosure.handle()auto-detects__invoke()on subclasses when$fnis null, so invokable tool classes work with or without->using($this).handle()unwrapsSerializableClosure\Serializers\Nativewrappers viagetClosure()before invocation, restoring PHP 8 named argument forwarding thatNative::__invoke()breaks.