{"record":{"id":"4e5884c5cd653d42","repo":"symfony/process","slug":"cannot-serialize-symfony-component-process-pipes","errorCode":null,"errorMessage":"Cannot serialize Symfony\\Component\\Process\\Pipes\\WindowsPipes","messagePattern":"Cannot serialize Symfony\\\\Component\\\\Process\\\\Pipes\\\\WindowsPipes","errorType":"exception","errorClass":"BadMethodCallException","httpStatus":null,"severity":"error","filePath":"Pipes/WindowsPipes.php","lineNumber":92,"sourceCode":"                        flock($this->lockHandles[$pipe], \\LOCK_UN);\n                        fclose($this->lockHandles[$pipe]);\n                        unset($this->lockHandles[$pipe]);\n                        continue 2;\n                    }\n                    $this->fileHandles[$pipe] = $h;\n                    $this->files[$pipe] = $file;\n                }\n                break;\n            }\n            restore_error_handler();\n        }\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('NUL', 'c');\n\n            return [","sourceCodeStart":74,"sourceCodeEnd":110,"githubUrl":"https://github.com/symfony/process/blob/99b85026db14a68f02c6f3eeb01a1170ca25c491/Pipes/WindowsPipes.php#L74-L110","documentation":"WindowsPipes manages temporary files and open handles used for process I/O on Windows; these OS-level resources cannot be serialized. __serialize() deliberately throws BadMethodCallException to prevent it.","triggerScenarios":"serialize($process->getProcessPipes()) or serializing any object graph containing a live WindowsPipes instance (e.g. a running Process stored in cache/session).","commonSituations":"Caching a running Process on a Windows host, queueing a live Process object, or serialize-based debug logging.","solutions":["Close/finish the process before persisting anything","Persist only serializable configuration and rebuild the Process on demand","Exclude the Process/pipes property from your object's __serialize()/__sleep()"],"exampleFix":"// before\npublic function __serialize(): array { return ['process' => $this->process]; }\n// after\npublic function __serialize(): array { return ['command' => $this->process->getCommandLine()]; }","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":["Exclude Process/pipes properties from serializable wrappers","Cache process descriptors, not objects","Test cache paths on Windows where pipes use temp files"],"tags":["serialization","windows","process","pipes"],"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"}