nfroidure / ttf2woff2

Convert ttf files to woff2.
MIT License
297 stars 39 forks source link

Disable Emscripten NODEJS_CATCH_EXIT and NODEJS_CATCH_REJECTION flags #64

Closed andersk closed 3 years ago

andersk commented 3 years ago

When using ttf2woff2 as a library (e.g. inside webfonts-loader), this was previously catching promise rejections from other code that had nothing to do with ttf2woff2.

See https://github.com/emscripten-core/emscripten/issues/7855.

Proposed changes

Code quality

License

To get your contribution merged, you must check the following.

Join

My NPM username: andersk

nfroidure commented 3 years ago

@andersk thanks for contributing. I feel like your change won't have any breaking impact on the existing users so I think I'll make a major version.

andersk commented 3 years ago

I agree it’s non-breaking. But surely you mean minor or patch, not major?

nfroidure commented 3 years ago

I meant major, when I'n not sure I won't break things, I prefer spawn a major than take the risk to break other's build.

andersk commented 3 years ago

I’d prefer a minor release, if possible; it took a lot of time to propagate the last major release all the way through the dependency chain (ttf2woff2 → @vusion/webfonts-generator → webfonts-loader, and I’m still waiting for ttf2woff2 → fontmin → font-subset-loader2).

andersk commented 3 years ago

Here is the entire beautified diff to jssrc/ttf2woff2.js, so you can see that the only change is to remove the handlers that abort on exceptions. (I compiled with exactly the same version of Emscripten to ensure that this diff would be small.) Removing an abort cannot break someone’s build.

@@ -60,12 +60,6 @@
   if (typeof module !== 'undefined') {
     module['exports'] = Module;
   }
-  process['on']('uncaughtException', function (ex) {
-    if (!(ex instanceof ExitStatus)) {
-      throw ex;
-    }
-  });
-  process['on']('unhandledRejection', abort);
   quit_ = function (status) {
     process['exit'](status);
   };
@@ -1695,11 +1689,6 @@
 Module['getValue'] = getValue;
 Module['writeArrayToMemory'] = writeArrayToMemory;
 var calledRun;
-function ExitStatus(status) {
-  this.name = 'ExitStatus';
-  this.message = 'Program terminated with exit(' + status + ')';
-  this.status = status;
-}
 dependenciesFulfilled = function runCaller() {
   if (!calledRun) run();
   if (!calledRun) dependenciesFulfilled = runCaller;
nfroidure commented 3 years ago

Ok, so let's release a patch then and cross fingers :P.