Browse Source

kernel: Fix nasty error.

st.seamless implementation broken the invariant:
"when there was no context on entry to ST,
there should be no context when leaving ST".

This meant, error handling was "switched off" whenever there was error
in a promises' then: or catch: block (as promises' handlers were
called using st.seamless - there's a good reason for that -
there may be (and should be) .catch somewhere down the chain).

st.seamless is fixed to return thisContext to null on leave
when it was null on entry.
Herby Vojčík 4 years ago
parent
commit
eefaf5b455
2 changed files with 17 additions and 1 deletions
  1. 8 0
      CHANGELOG
  2. 9 1
      lang/base/kernel-runtime.js

+ 8 - 0
CHANGELOG

@@ -1,3 +1,11 @@
+12 Apr 2020 - Release 0.25.3
+===================================
+
+* Fix error handling broken by errors happening in Promises.
+
+Commits: https://lolg.it/amber/amber/commits/0.25.3
+
+
 11 Apr 2020 - Release 0.25.2
 11 Apr 2020 - Release 0.25.2
 ===================================
 ===================================
 
 

+ 9 - 1
lang/base/kernel-runtime.js

@@ -355,6 +355,14 @@ define(['./junk-drawer'], function ($goodies) {
 
 
             var thisContext = null;
             var thisContext = null;
 
 
+            function resultWithNoErrorHandling (worker) {
+                try {
+                    return worker(thisContext);
+                } finally {
+                    thisContext = null;
+                }
+            }
+
             /*
             /*
              Runs worker function so that error handler is not set up
              Runs worker function so that error handler is not set up
              if there isn't one. This is accomplished by unconditional
              if there isn't one. This is accomplished by unconditional
@@ -368,7 +376,7 @@ define(['./junk-drawer'], function ($goodies) {
                 thisContext = new SmalltalkMethodContext(thisContext, function (ctx) {
                 thisContext = new SmalltalkMethodContext(thisContext, function (ctx) {
                     ctx.fill(null, "seamlessDoIt", {}, globals.UndefinedObject);
                     ctx.fill(null, "seamlessDoIt", {}, globals.UndefinedObject);
                 });
                 });
-                var result = worker(thisContext);
+                var result = oldContext == null ? resultWithNoErrorHandling(worker) : worker(thisContext);
                 thisContext = oldContext;
                 thisContext = oldContext;
                 return result;
                 return result;
             };
             };