{"record":{"id":"0e761a822c1aa9f6","repo":"symfony/process","slug":"cannot-serialize-symfony-component-process-pipes-unixpipes","errorCode":null,"errorMessage":"Cannot serialize Symfony\\Component\\Process\\Pipes\\UnixPipes","messagePattern":"Cannot serialize Symfony\\\\Component\\\\Process\\\\Pipes\\\\UnixPipes","errorType":"exception","errorClass":"BadMethodCallException","httpStatus":null,"severity":"error","filePath":"Pipes/UnixPipes.php","lineNumber":36,"sourceCode":" *\n * @author Romain Neutron <imprec@gmail.com>\n *\n * @internal\n */\nclass UnixPipes extends AbstractPipes\n{\n    public function __construct(\n        private ?bool $ttyMode,\n        private bool $ptyMode,\n        mixed $input,\n        private bool $haveReadSupport,\n    ) {\n        parent::__construct($input);\n    }\n\n    public function __serialize(): array\n    {\n        throw new \\BadMethodCallException('Cannot serialize '.__CLASS__);\n    }\n\n    public function __unserialize(array $data): void\n    {\n        throw new \\BadMethodCallException('Cannot unserialize '.__CLASS__);\n    }\n\n    public function __destruct()\n    {\n        $this->close();\n    }\n\n    public function getDescriptors(): array\n    {\n        if (!$this->haveReadSupport) {\n            $nullstream = fopen('/dev/null', 'c');\n\n            return [","sourceCodeStart":18,"sourceCodeEnd":54,"githubUrl":"https://github.com/symfony/process/blob/99b85026db14a68f02c6f3eeb01a1170ca25c491/Pipes/UnixPipes.php#L18-L54","documentation":"UnixPipes holds open OS file descriptors for process I/O, which cannot be meaningfully captured by PHP serialization. Attempting to serialize() a UnixPipes instance triggers __serialize(), which deliberately throws BadMethodCallException.","triggerScenarios":"serialize($process->getProcessPipes()), serializing an object graph that contains live UnixPipes (e.g. serializing a running Process or storing it in a serializable cache/session).","commonSituations":"Putting a live Process into a session, cache, or queue payload while it is running; var_export/serialize debugging of a running process.","solutions":["Do not serialize objects holding live pipes; finish or close the process first","Store only serializable state (commandline, cwd, env) and recreate the Process later via new Process(...)","Exclude the pipes/Process property from serialization using __sleep()/__serialize() on the enclosing class"],"exampleFix":"// before\n$cache->set('job', $process); // contains live pipes\n// after\n$cache->set('job', ['command' => $process->getCommandLine(), 'cwd' => $process->getWorkingDirectory()]);","handlingStrategy":"type-guard","validationCode":"if ($process->isRunning()) { throw new \\LogicException('Cannot persist a running process'); }","typeGuard":"function isSerializable(mixed $v): bool { try { serialize($v); return true; } catch (\\Throwable) { return false; } }","tryCatchPattern":"try { $data = serialize($obj); } catch (\\BadMethodCallException $e) { $data = serialize($obj->toDescriptor()); }","preventionTips":["Never put live Process or pipes objects in caches/sessions","Persist process descriptors (command, cwd, env) instead of objects","Audit classes with resource properties for __serialize guards before caching"],"tags":["serialization","process","pipes","unsupported-operation"],"backgroundTag":"json-serialization-failed","analyzedSha":"99b85026db14a68f02c6f3eeb01a1170ca25c491","analyzedAt":"2026-09-14T11:23:33.683Z","contentChangedAt":"2026-09-14T11:23:33.683Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}