Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Xdebug has detected a possible infinite loop, and aborted your script with a stack depth of '512' frames #620

Closed
mo7ameds7awky opened this issue Nov 7, 2024 · 21 comments

Comments

@mo7ameds7awky
Copy link

mo7ameds7awky commented Nov 7, 2024

php version: 8.3.13
Xdebug v3.3.1
Zend OPcache v8.3.13
laravel version: 11.9
scramble version: 0.11.25

when i installed Scramble for my existing laravel project, then I visited the /docs/api route it shows error:
Xdebug has detected a possible infinite loop, and aborted your script with a stack depth of '512' frames

@romalytvynenko
Copy link
Member

@mo7ameds7awky any indication which route causes that? I really cannot help without reproduction.

@mo7ameds7awky
Copy link
Author

mo7ameds7awky commented Nov 7, 2024

@romalytvynenko when I visit /docs/api i get this error, and there is no indication in the stack trace to another route/file

@romalytvynenko
Copy link
Member

@mo7ameds7awky I meant there is some route of your application (not /docs/api) that is causing this error when being analyzed. It may be visible in full stack trace. You gave me no info

@mo7ameds7awky
Copy link
Author

mo7ameds7awky commented Nov 7, 2024

@romalytvynenko Yes sorry, here is the full trace with the logs you are generating

[2024-11-07 07:56:22] local.ERROR: Error when analyzing route 'PATCH api/users/profile/personal-info' (App\Http\Controllers\Users\Me\Profiles\UpdatePersonalInfoController@__invoke): Xdebug has detected a possible infinite loop, and aborted your script with a stack depth of '512' frames – /vendor/laravel/framework/src/Illuminate/Collections/Traits/EnumeratesValues.php on line 1052

@romalytvynenko
Copy link
Member

@mo7ameds7awky App\Http\Controllers\Users\Me\Profiles\UpdatePersonalInfoController@invoke

Please send the source code of this method

@mo7ameds7awky
Copy link
Author

@romalytvynenko as I can NOT share the source code but I will give an idea of what is going on in the controller

<?php

class UpdatePersonalInfoController extends Controller
{
    public function __invoke(Request $request)
    {
        $user = $request->user();

        $bank = Bank::firstWhere('uuid', $request->input('bank_id'));

        $this->validateSomeRequestData($request->input('input'), $otherParam);

        $someData = Arr::except($request->validated(), [...comeFIelds);

        $user->update($someData);

        $someOtherData = Arr::only($request->validated(), [...someFields]);

        $user->relation()->updateOrCreate([], $someOtherData);

        return SomeResource::make($user->loadMissing([...someRelations]));
    }

    private function validateSomeRequestData($parameter, $otherParameter)
    {
        if (! SomeClass::function($parameter, $otherParameter)) {
            throw ValidationException::withMessages(...someParams)->errorBag('param_name');
        }
    }
}

@romalytvynenko
Copy link
Member

@mo7ameds7awky if you cannot share the code, you can create a reproduction. You can simply clone this repo https://github.com/dedoc/demo-scramble and try reproducing the issue by using same code patterns, both in controller, in the JSON resource, in models, etc.

Without either repro or the codebase I am not able to help.

@mo7ameds7awky
Copy link
Author

@romalytvynenko The code I provided is the same as I have but with a dummy name, with that, you can't help also?!!

@romalytvynenko
Copy link
Member

@mo7ameds7awky try cloning that demo repo I shared and paste the code you shared there. Is the issue reproducing?

@romalytvynenko
Copy link
Member

@mo7ameds7awky the issue is in the SomeResource code. But again, the source is needed

@romalytvynenko
Copy link
Member

@mo7ameds7awky there is some conditional method call (when, mergeWhen, etc) that causes this. But again, the source is needed (🙈)

@mo7ameds7awky
Copy link
Author

@romalytvynenko Thanks for the support, but unfortunately I can't share the code, but we can leave this issue until someone faces the issue and has permission to share the code, if I had the time I would try to imitate the code and try the demo repo approach you suggested to me

@romalytvynenko
Copy link
Member

@mo7ameds7awky you can check and share the info about specific conditional methods calls in the resource, that will also help. No need in sharing the source

@mo7ameds7awky
Copy link
Author

@romalytvynenko I use whenLoaded method

@romalytvynenko
Copy link
Member

@mo7ameds7awky what types of arguments are you passing there? Can you share some pseudo code that will allow me to understand that?

@mo7ameds7awky
Copy link
Author

mo7ameds7awky commented Nov 7, 2024

@romalytvynenko SomeResource::make($this->whenLoaded('relation'))

@romalytvynenko
Copy link
Member

@mo7ameds7awky I mean inside SomeResource class. In toArray method.

@romalytvynenko
Copy link
Member

Closing the issue as I cannot reproduce. Something is clearly off, but without more engagement and willing to spend some time here to help me with repro, I cannot help.

@romalytvynenko romalytvynenko closed this as not planned Won't fix, can't repro, duplicate, stale Nov 7, 2024
@morloderex
Copy link

@mo7ameds7awky Try to disable xdebug.

@mo7ameds7awky
Copy link
Author

mo7ameds7awky commented Nov 13, 2024

@morloderex it's more of a workaround than a solution, thanks though, i started to use scribe which works perfectly with XDebug enabled, it's a little bit frustrating to describe your APIs, but it will satisfy my needs, i hope this issue fixed for other people that wants to use scramble

@romalytvynenko
Copy link
Member

The reason of this issue (or at least one them) has been fixed in 0.11.32: https://github.com/dedoc/scramble/releases/tag/v0.11.32

@jaimyborgman @morloderex

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

No branches or pull requests

3 participants