mirror of
https://github.com/denoland/deno.git
synced 2025-01-11 08:33:43 -05:00
This reverts commit
83426be6ee
.
Includes a regression test.
This commit is contained in:
parent
2cc7c8432f
commit
9e243d22f4
4 changed files with 25 additions and 14 deletions
|
@ -756,3 +756,20 @@ Deno.test({
|
||||||
assertEquals(timeoutsFired.length, 300);
|
assertEquals(timeoutsFired.length, 300);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Regression test for https://github.com/denoland/deno/issues/20367
|
||||||
|
Deno.test({
|
||||||
|
name: "regression for #20367",
|
||||||
|
fn: async () => {
|
||||||
|
const promise = deferred<number>();
|
||||||
|
const start = performance.now();
|
||||||
|
setTimeout(() => {
|
||||||
|
const end = performance.now();
|
||||||
|
promise.resolve(end - start);
|
||||||
|
}, 1000);
|
||||||
|
clearTimeout(setTimeout(() => {}, 1000));
|
||||||
|
|
||||||
|
const result = await promise;
|
||||||
|
assert(result >= 1000);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
use crate::hr_timer_lock::hr_timer_lock;
|
use crate::hr_timer_lock::hr_timer_lock;
|
||||||
use deno_core::error::AnyError;
|
use deno_core::error::AnyError;
|
||||||
use deno_core::op;
|
use deno_core::op;
|
||||||
use deno_core::op2;
|
|
||||||
use deno_core::CancelFuture;
|
use deno_core::CancelFuture;
|
||||||
use deno_core::CancelHandle;
|
use deno_core::CancelHandle;
|
||||||
use deno_core::OpState;
|
use deno_core::OpState;
|
||||||
|
@ -80,15 +79,13 @@ pub fn op_timer_handle(state: &mut OpState) -> ResourceId {
|
||||||
/// [`TimerHandle`] resource given by `rid` has been canceled.
|
/// [`TimerHandle`] resource given by `rid` has been canceled.
|
||||||
///
|
///
|
||||||
/// If the timer is canceled, this returns `false`. Otherwise, it returns `true`.
|
/// If the timer is canceled, this returns `false`. Otherwise, it returns `true`.
|
||||||
#[op2(async(lazy))]
|
#[op(deferred)]
|
||||||
pub async fn op_sleep(
|
pub async fn op_sleep(
|
||||||
state: Rc<RefCell<OpState>>,
|
state: Rc<RefCell<OpState>>,
|
||||||
#[bigint] millis: u64,
|
millis: u64,
|
||||||
#[smi] rid: ResourceId,
|
rid: ResourceId,
|
||||||
) -> Result<bool, AnyError> {
|
) -> Result<bool, AnyError> {
|
||||||
let Ok(handle) = state.borrow().resource_table.get::<TimerHandle>(rid) else {
|
let handle = state.borrow().resource_table.get::<TimerHandle>(rid)?;
|
||||||
return Ok(true);
|
|
||||||
};
|
|
||||||
|
|
||||||
// If a timer is requested with <=100ms resolution, request the high-res timer. Since the default
|
// If a timer is requested with <=100ms resolution, request the high-res timer. Since the default
|
||||||
// Windows timer period is 15ms, this means a 100ms timer could fire at 115ms (15% late). We assume that
|
// Windows timer period is 15ms, this means a 100ms timer could fire at 115ms (15% late). We assume that
|
||||||
|
|
|
@ -5,7 +5,6 @@ use deno_core::error::invalid_hostname;
|
||||||
use deno_core::error::type_error;
|
use deno_core::error::type_error;
|
||||||
use deno_core::error::AnyError;
|
use deno_core::error::AnyError;
|
||||||
use deno_core::op;
|
use deno_core::op;
|
||||||
use deno_core::op2;
|
|
||||||
use deno_core::url;
|
use deno_core::url;
|
||||||
use deno_core::AsyncMutFuture;
|
use deno_core::AsyncMutFuture;
|
||||||
use deno_core::AsyncRefCell;
|
use deno_core::AsyncRefCell;
|
||||||
|
@ -529,12 +528,12 @@ pub async fn op_ws_send_ping(
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
#[op2(async(lazy))]
|
#[op(deferred)]
|
||||||
pub async fn op_ws_close(
|
pub async fn op_ws_close(
|
||||||
state: Rc<RefCell<OpState>>,
|
state: Rc<RefCell<OpState>>,
|
||||||
#[smi] rid: ResourceId,
|
rid: ResourceId,
|
||||||
code: Option<u16>,
|
code: Option<u16>,
|
||||||
#[string] reason: Option<String>,
|
reason: Option<String>,
|
||||||
) -> Result<(), AnyError> {
|
) -> Result<(), AnyError> {
|
||||||
let resource = state
|
let resource = state
|
||||||
.borrow_mut()
|
.borrow_mut()
|
||||||
|
|
|
@ -6,7 +6,6 @@ use crate::web_worker::WebWorkerInternalHandle;
|
||||||
use crate::web_worker::WebWorkerType;
|
use crate::web_worker::WebWorkerType;
|
||||||
use deno_core::error::AnyError;
|
use deno_core::error::AnyError;
|
||||||
use deno_core::op;
|
use deno_core::op;
|
||||||
use deno_core::op2;
|
|
||||||
|
|
||||||
use deno_core::CancelFuture;
|
use deno_core::CancelFuture;
|
||||||
use deno_core::OpState;
|
use deno_core::OpState;
|
||||||
|
@ -38,8 +37,7 @@ fn op_worker_post_message(
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[op2(async(lazy))]
|
#[op(deferred)]
|
||||||
#[serde]
|
|
||||||
async fn op_worker_recv_message(
|
async fn op_worker_recv_message(
|
||||||
state: Rc<RefCell<OpState>>,
|
state: Rc<RefCell<OpState>>,
|
||||||
) -> Result<Option<JsMessageData>, AnyError> {
|
) -> Result<Option<JsMessageData>, AnyError> {
|
||||||
|
|
Loading…
Reference in a new issue