summaryrefslogtreecommitdiff
path: root/core/01_core.js
diff options
context:
space:
mode:
Diffstat (limited to 'core/01_core.js')
-rw-r--r--core/01_core.js19
1 files changed, 16 insertions, 3 deletions
diff --git a/core/01_core.js b/core/01_core.js
index a13bdc8dd..c46c30070 100644
--- a/core/01_core.js
+++ b/core/01_core.js
@@ -191,12 +191,24 @@
return res;
}
- function rollPromiseId() {
- return nextPromiseId++;
+ function opAsync2(name, arg0, arg1) {
+ const id = nextPromiseId++;
+ let promise = PromisePrototypeThen(setPromise(id), unwrapOpResult);
+ try {
+ ops[name](id, arg0, arg1);
+ } catch (err) {
+ // Cleanup the just-created promise
+ getPromise(id);
+ // Rethrow the error
+ throw err;
+ }
+ promise = handleOpCallTracing(name, id, promise);
+ promise[promiseIdSymbol] = id;
+ return promise;
}
function opAsync(name, ...args) {
- const id = rollPromiseId();
+ const id = nextPromiseId++;
let promise = PromisePrototypeThen(setPromise(id), unwrapOpResult);
try {
ops[name](id, ...new SafeArrayIterator(args));
@@ -376,6 +388,7 @@
// Extra Deno.core.* exports
const core = ObjectAssign(globalThis.Deno.core, {
opAsync,
+ opAsync2,
resources,
metrics,
registerErrorBuilder,