Repository: appwrite/appwrite
File: src/Appwrite/Platform/Modules/Functions/Workers/Builds.php (PHP)

Code before:
                    $previewUrl = match($resource->getCollection()) {
                        'functions' => '',
                        'sites' => !empty($rule) ? ("{$protocol}://" . $rule->getAttribute('domain', '')) : '',
                        default => throw new \Exception('Invalid resource type')
                    };

                    $comment = new Comment();
                    $comment->parseComment($github->getComment($owner, $repositoryName, $commentId));
                    $comment->addBuild($project, $resource, $resourceType, $status, $deployment->getId(), ['type' => 'logs'], $previewUrl);
                    $github->updateComment($owner, $repositoryName, $commentId, $comment->generateComment());
                } finally {
                    $dbForPlatform->deleteDocument('vcsCommentLocks', $commentId);
                }
            }
        } catch (\Throwable $th) {
            Console::warning("Git action failed:");
            Console::warning($th->getMessage());
            Console::warning($th->getTraceAsString());

            $logs = $deployment->getAttribute('buildLogs', '');
            $date = \date('H:i:s');
            $logs .= "[90m[$date] [90m[[0mappwrite[90m][33m Git action failed. Deployment will continue. [0m\n";

            $deployment->setAttribute('buildLogs', $logs);
            $deployment = $dbForProject->updateDocument('deployments', $deployment->getId(), $deployment);
        }
    }

    private function cancelDeployment(string $deploymentId, Database $dbForProject, Realtime $queueForRealtime)
    {
        Console::info('Build has been canceled');

        $deployment = $dbForProject->getDocument('deployments', $deploymentId);

        $logs = $deployment->getAttribute('buildLogs', '');
        $date = \date('H:i:s');
        $logs .= "[90m[$date] [90m[[0mappwrite[90m][33m Build has been canceled. [0m\n";

        $deployment->setAttribute('buildLogs', $logs);
        $deployment = $dbForProject->updateDocument('deployments', $deployment->getId(), $deployment);

        $queueForRealtime
            ->setPayload($deployment->getArrayCopy())
            ->trigger();
    }
}


Review comment (suggestion):
1 tiny detail, we need to trigger realtime here, because logs changed. like here https://github.com/appwrite/appwrite/blob/cd39bd65125238564360d56c297cce8e6010c27e/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php#L1035-L1037

Code after:
                    $protocol = System::getEnv('_APP_OPTIONS_FORCE_HTTPS') == 'disabled' ? 'http' : 'https';
                    $previewUrl = match($resource->getCollection()) {
                        'functions' => '',
                        'sites' => !empty($rule) ? ("{$protocol}://" . $rule->getAttribute('domain', '')) : '',
                        default => throw new \Exception('Invalid resource type')
                    };

                    $comment = new Comment();
                    $comment->parseComment($github->getComment($owner, $repositoryName, $commentId));
                    $comment->addBuild($project, $resource, $resourceType, $status, $deployment->getId(), ['type' => 'logs'], $previewUrl);
                    $github->updateComment($owner, $repositoryName, $commentId, $comment->generateComment());
                } finally {
                    $dbForPlatform->deleteDocument('vcsCommentLocks', $commentId);
                }
            }
        } catch (\Throwable $th) {
            Console::warning("Git action failed:");
            Console::warning($th->getMessage());
            Console::warning($th->getTraceAsString());

            $logs = $deployment->getAttribute('buildLogs', '');
            $date = \date('H:i:s');
            $logs .= "[90m[$date] [90m[[0mappwrite[90m][33m Git action failed. Deployment will continue. [0m\n";

            $deployment->setAttribute('buildLogs', $logs);
            $deployment = $dbForProject->updateDocument('deployments', $deployment->getId(), $deployment);

            $queueForRealtime
                ->setPayload($deployment->getArrayCopy())
                ->trigger();
        }
    }

    private function cancelDeployment(string $deploymentId, Database $dbForProject, Realtime $queueForRealtime)
    {
        Console::info('Build has been canceled');

        $deployment = $dbForProject->getDocument('deployments', $deploymentId);

        $logs = $deployment->getAttribute('buildLogs', '');
        $date = \date('H:i:s');
        $logs .= "[90m[$date] [90m[[0mappwrite[90m][33m Build has been canceled. [0m\n";

        $deployment->setAttribute('buildLogs', $logs);
        $deployment = $dbForProject->updateDocument('deployments', $deployment->getId(), $deployment);

        $queueForRealtime
            ->setPayload($deployment->getArrayCopy())
            ->trigger();
    }
}