summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/01_core.js11
1 files changed, 8 insertions, 3 deletions
diff --git a/core/01_core.js b/core/01_core.js
index fda3e4977..e5e2c9fd5 100644
--- a/core/01_core.js
+++ b/core/01_core.js
@@ -161,9 +161,14 @@
function opAsync(opName, ...args) {
const promiseId = nextPromiseId++;
let p = setPromise(promiseId);
- const maybeError = ops[opName](promiseId, ...args);
- // Handle sync error (e.g: error parsing args)
- if (maybeError) return unwrapOpResult(maybeError);
+ try {
+ ops[opName](promiseId, ...args);
+ } catch (err) {
+ // Cleanup the just-created promise
+ getPromise(promiseId);
+ // Rethrow the error
+ throw err;
+ }
p = PromisePrototypeThen(p, unwrapOpResult);
if (opCallTracingEnabled) {
// Capture a stack trace by creating a new `Error` object. We remove the