GWicke has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/257771

Change subject: Add a hack to work around Parsoid's fatal exiting logger 
expectation
......................................................................

Add a hack to work around Parsoid's fatal exiting logger expectation

Change-Id: I1eb9300af7da54e18590f99b2f1d275f6afa8dd2
---
M lib/index.js
1 file changed, 24 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/parsoid 
refs/changes/71/257771/1

diff --git a/lib/index.js b/lib/index.js
index 5186ac0..9ad3409 100644
--- a/lib/index.js
+++ b/lib/index.js
@@ -145,5 +145,28 @@
  */
 Parsoid.apiServiceWorker = function apiServiceWorker(options) {
        var parsoidConfig = new ParsoidConfig(null, options.config);
-       return ParsoidService.init(parsoidConfig, options.logger);
+
+       // Hack: Parsoid currently relies on the logger to exit after logging a
+       // fatal. Emulate this with a small wrapper.
+       // TODO: Perhaps ask the logger to return a promise & exit when that
+       // fires? Do the timeout thing here in a delayedExit utility in Parsoid?
+       var hackyLogger = {
+               log: function() {
+                       // Copy arguments to preserve optimization
+                       var args = new Array(arguments.length);
+                       for (var i = 0; i < arguments.length; i++) {
+                               args[i] = arguments[i];
+                       }
+                       options.logger.log.apply(options.logger, args);
+                       if (/^fatal\b/.test(args[0])) {
+                               // Hack for Parsoid: Delay a bit to give the 
logger time to do
+                               // its thing, then exit.
+                               setTimeout(function() {
+                                       process.exit(1);
+                               }, 1000);
+                       }
+               }
+       };
+
+       return ParsoidService.init(parsoidConfig, hackyLogger);
 };

-- 
To view, visit https://gerrit.wikimedia.org/r/257771
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I1eb9300af7da54e18590f99b2f1d275f6afa8dd2
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/parsoid
Gerrit-Branch: master
Gerrit-Owner: GWicke <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to