WordPress/wordpress-playground

PHP: Don't throw ExitStatus 0

Closed this issue · 5 comments

As seen in https://github.com/WordPress/wordpress-playground/pull/451/files#diff-a063d4a01f49cda0eb3523f6cf5f33e7f7f033407effb7ed7d4c4dffb24fe84d, php may throw an error that indicates exit status 0. This is a bug, as 0 means everything executed successfully and no errors were encountered. Let's find the root cause and either prevent the error from being thrown at all, or silence it at the framework level.

	try {
		php.useHostFilesystem();
		await php.cli(phpArgs);
	} catch (resultOrError) {
		const success =
			resultOrError.name === 'ExitStatus' && resultOrError.status === 0;
		if (!success) {
			throw resultOrError;
		}
	}

Would also like more info on this. @adamziel Your fix above has helped continue with my Node app's execution, but I'm still trying to find a way around the large "WASM ERROR" output that appears regardless of the try/catch.

For more context, this small code block:

try {
    await php.cli(['php', '-c', './php.ini', './vendor/bin/composer', 'require', 'symfony/var-dumper']);
} catch (resultOrError) {
    const success = resultOrError.name === 'ExitStatus' && resultOrError.status === 0;
    if (!success) {
        throw resultOrError;
    }
}

is returning an exit code of 0, success, but still displaying the large error box from the showCriticalErrorBox method.

Screenshot 2023-06-20 at 2 54 04 AM

Thank you for the reproduction @aschmelyun! I just started #575 to fix this

Wow, that was fast! Thanks for the top-notch work 👍

Solved by #955 and #575.