Skip to content

FlameChart issues when call stack is deeper than 512 #300

@downace

Description

@downace

I found already merged PR #275. But it's still not working.

I'm getting 500 response and error in logs:

TypeError: fwrite(): Argument #2 ($data) must be of type string, false given in /app/vendor/nyholm/psr7/src/Stream.php at line 228

I guess this is because returned array is JSON encoded before sending response, and depth parameter is not specified here:

        $response->getBody()->write(\json_encode($payload));

This happens only on first FlameChart request, before it's cached in filesystem. After that, I'm getting another error:

Modules\Profiler\Interfaces\Queries\FindFlameChartByUuidHandler::__invoke(): Return value must be of type array|string, null returned

The depth parameter is also not specified in this line:

if ($this->bucket->exists($file)) {
return \json_decode($this->bucket->getContents($file), true);
}


Solution that worked in my case: return JSON string directly instead of array:

         if ($this->bucket->exists($file)) {
-            return \json_decode($this->bucket->getContents($file), true);
+            return $this->bucket->getContents($file);
         }
-        $this->bucket->write($file, \json_encode($waterfall, 0, 5000));
+        $response = \json_encode($waterfall, 0, 5000);
+        $this->bucket->write($file, $response);
 
-        return $waterfall;
+        return $response;
     }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions