From f520b3ee7ab1173ab9c277ec209a4daa98b378c2 Mon Sep 17 00:00:00 2001 From: Antonio Sejas Date: Fri, 22 Mar 2024 12:49:44 +0000 Subject: [PATCH] Revert "WP-NOW: Use rotatePHPRuntime to avoid memory error (#152)" This reverts commit 6f7c5dba247b2110bad28e91737688d87af14f79. --- packages/wp-now/src/wp-now.ts | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/packages/wp-now/src/wp-now.ts b/packages/wp-now/src/wp-now.ts index 4dd02db5..d95ac898 100644 --- a/packages/wp-now/src/wp-now.ts +++ b/packages/wp-now/src/wp-now.ts @@ -1,6 +1,5 @@ import fs from 'fs-extra'; -import { NodePHP, PHPRequestHandlerConfiguration } from '@php-wasm/node'; -import { rotatePHPRuntime } from '@php-wasm/universal'; +import { NodePHP, PHPLoaderOptions } from '@php-wasm/node'; import path from 'path'; import { SQLITE_FILENAME } from './constants'; import { @@ -43,23 +42,20 @@ export default async function startWPNow( options: Partial = {} ): Promise<{ php: NodePHP; phpInstances: NodePHP[]; options: WPNowOptions }> { const { documentRoot } = options; - const nodePHPOptions: PHPRequestHandlerConfiguration = { - documentRoot, - absoluteUrl: options.absoluteUrl, + const nodePHPOptions: PHPLoaderOptions = { + requestHandler: { + documentRoot, + absoluteUrl: options.absoluteUrl, + }, }; const phpInstances = []; - const loadRuntime = async () => - await NodePHP.loadRuntime(options.phpVersion); for (let i = 0; i < Math.max(options.numberOfPhpInstances, 1); i++) { - phpInstances.push(new NodePHP(await loadRuntime(), nodePHPOptions)); + phpInstances.push( + await NodePHP.load(options.phpVersion, nodePHPOptions) + ); } const php = phpInstances[0]; - await rotatePHPRuntime({ - php, - recreateRuntime: loadRuntime, - maxRequests: 100, - }); phpInstances.forEach((_php) => { _php.mkdirTree(documentRoot);