WordPress/wordpress-playground

PHP: Turn ExitStatus into a subclass of Error

adamziel opened this issue · 2 comments

As seen in #416, unexpected WASM crashes throw an ExitStatus instance without any stack trace attached. This makes debugging and reporting very difficult. Emscripten does it on purpose to prevent memory leaks during shutdown, but we want to kill the entire process on failure so memory leaks are not a big issue.

This is the change we need to ensure in php.js – it could be by patching the file or re-assigning the ExitStatus value in the Playground JS library for Emscripten:

  class ExitStatus extends Error {
	  constructor(status) {
		  super(status);
		  this.name = "ExitStatus";
		  this.message = "Program terminated with exit(" + status + ")";
		  this.status = status;
	  }
  }

Kudos to @wojtekn for identifying the problem

Fixing this could potentially give us better error information in #346

Solved in #470