summaryrefslogtreecommitdiff
path: root/ext/web
diff options
context:
space:
mode:
authorsnek <snek@deno.com>2024-08-02 11:16:59 -0700
committerGitHub <noreply@github.com>2024-08-02 18:16:59 +0000
commit71ca61e189cca9215982ce4598b7a4da8430c584 (patch)
treea0dd2aa94cf61103b1dbcfa28a6c67feebf6eedd /ext/web
parent3a1a1cc030fb7fc90d51ee27162466d6ac924926 (diff)
Revert "feat: async context" (#24856)
Reverts denoland/deno#24402 deno_web can't depend on code in runtime
Diffstat (limited to 'ext/web')
-rw-r--r--ext/web/02_timers.js52
1 files changed, 16 insertions, 36 deletions
diff --git a/ext/web/02_timers.js b/ext/web/02_timers.js
index a651df5a5..559147861 100644
--- a/ext/web/02_timers.js
+++ b/ext/web/02_timers.js
@@ -2,10 +2,6 @@
import { core, primordials } from "ext:core/mod.js";
import { op_defer, op_now } from "ext:core/ops";
-import {
- getAsyncContext,
- setAsyncContext,
-} from "ext:runtime/01_async_context.js";
const {
Uint8Array,
Uint32Array,
@@ -37,16 +33,14 @@ function checkThis(thisArg) {
* Call a callback function immediately.
*/
function setImmediate(callback, ...args) {
- const asyncContext = getAsyncContext();
- return core.queueImmediate(() => {
- const oldContext = getAsyncContext();
- try {
- setAsyncContext(asyncContext);
- return ReflectApply(callback, globalThis, args);
- } finally {
- setAsyncContext(oldContext);
- }
- });
+ if (args.length > 0) {
+ const unboundCallback = callback;
+ callback = () => ReflectApply(unboundCallback, globalThis, args);
+ }
+
+ return core.queueImmediate(
+ callback,
+ );
}
/**
@@ -59,17 +53,10 @@ function setTimeout(callback, timeout = 0, ...args) {
const unboundCallback = webidl.converters.DOMString(callback);
callback = () => indirectEval(unboundCallback);
}
- const unboundCallback = callback;
- const asyncContext = getAsyncContext();
- callback = () => {
- const oldContext = getAsyncContext();
- try {
- setAsyncContext(asyncContext);
- ReflectApply(unboundCallback, globalThis, args);
- } finally {
- setAsyncContext(oldContext);
- }
- };
+ if (args.length > 0) {
+ const unboundCallback = callback;
+ callback = () => ReflectApply(unboundCallback, globalThis, args);
+ }
timeout = webidl.converters.long(timeout);
return core.queueUserTimer(
core.getTimerDepth() + 1,
@@ -88,17 +75,10 @@ function setInterval(callback, timeout = 0, ...args) {
const unboundCallback = webidl.converters.DOMString(callback);
callback = () => indirectEval(unboundCallback);
}
- const unboundCallback = callback;
- const asyncContext = getAsyncContext();
- callback = () => {
- const oldContext = getAsyncContext(asyncContext);
- try {
- setAsyncContext(asyncContext);
- ReflectApply(unboundCallback, globalThis, args);
- } finally {
- setAsyncContext(oldContext);
- }
- };
+ if (args.length > 0) {
+ const unboundCallback = callback;
+ callback = () => ReflectApply(unboundCallback, globalThis, args);
+ }
timeout = webidl.converters.long(timeout);
return core.queueUserTimer(
core.getTimerDepth() + 1,