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

Promises are not handled correctly in processReinstallOperation #118

Open
LeanderFS opened this issue Feb 11, 2025 · 0 comments · May be fixed by #119
Open

Promises are not handled correctly in processReinstallOperation #118

LeanderFS opened this issue Feb 11, 2025 · 0 comments · May be fixed by #119

Comments

@LeanderFS
Copy link

While testing another issue locally, I encountered an issue which happens when you clear the composer cache before running on of the patch commands (e.g. patch:redo). The processReinstallOperation, and more specifically the download part, seems to resolve the promise too early without waiting for download completion, resulting in an empty package directory while patching.
The issue is clearly reproducible by adding some debug information to the promise chain in processReinstallOperation, which shows that the patch operation happens before the installation of the package.

I managed to resolve the issue by using the Composer\Utils\SyncHelper::downloadAndInstallPackageSync but this incurs passing the Composer object around. I'm not well versed in composer plugins but will make a PR regardless.

To Reproduce
Steps to reproduce the behavior:

  1. Run composer clear-cache
  2. Run composer patch:redo --vvv

Optionally change the processReinstallOperation to add debug information

        return $installationManager
            ->uninstall($repository, $uninstallOperation)
            ->then(function () use ($installationManager, $installOperation, $repository) {
                echo "Package uninstalled \n";
                $package = $installOperation->getPackage();
                return $installationManager->getInstaller($package->getType())->download($package);
            })
            ->then(function () use ($installationManager, $installOperation, $repository) {
                echo "Package downloaded \n";
                $installationManager->install($repository, $installOperation);
            })->then(function () {
                echo "Package installed \n";
            });

Expected
Packages are downloaded and installed before attempting to patch.

Actual
Packages are downloaded but patching begins before the installation process completed.

LeanderFS pushed a commit to LeanderFS/composer-patches that referenced this issue Feb 11, 2025
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

Successfully merging a pull request may close this issue.

1 participant