Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unstable Deno.sleepSync #14719

Merged
merged 5 commits into from
Jun 13, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix tests.
  • Loading branch information
dsherret committed May 26, 2022
commit 7b93dc45e4b610a1965eb3b49b434e7894215ce4
11 changes: 5 additions & 6 deletions cli/tests/testdata/worker_drop_handle_race_terminate.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,11 @@ const WORKER2 = getCodeBlobUrl(`
console.log("Worker 2");
self.postMessage(undefined);

// We sleep for slightly under 2 seconds in order to make sure that worker 1
// has closed, and that this worker's thread finishes normally rather than
// being killed (which happens 2 seconds after calling terminate).
setTimeout(() => {
console.log("Finished sleeping in worker 2");
}, 1800);
// We sleep synchronously for slightly under 2 seconds in order to make sure
// that worker 1 has closed, and that this worker's thread finishes normally
// rather than being killed (which happens 2 seconds after calling terminate).
Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, 1800);
console.log("Finished sleeping in worker 2");
`);

const WORKER1 = getCodeBlobUrl(`
Expand Down
2 changes: 1 addition & 1 deletion cli/tests/unit/flock_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ function runFlockTestProcess(opts: { exclusive: boolean; sync: boolean }) {
// the lock so that the enter time of the next process doesn't
// occur at the same time as this exit time
const exitTime = new Date().getTime();
Deno.sleepSync(100);
await new Promise(resolve => setTimeout(resolve, 100));

// release the lock
${opts.sync ? "Deno.funlockSync(rid);" : "await Deno.funlock(rid);"}
Expand Down
10 changes: 5 additions & 5 deletions cli/tests/unit/timers_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,10 +212,10 @@ Deno.test(async function callbackTakesLongerThanInterval() {
const promise = deferred();

let timeEndOfFirstCallback: number | undefined;
const interval = setInterval(async () => {
const interval = setInterval(() => {
if (timeEndOfFirstCallback === undefined) {
// First callback
await delay(300);
Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, 300);
timeEndOfFirstCallback = Date.now();
} else {
// Second callback
Expand All @@ -236,8 +236,8 @@ Deno.test(async function clearTimeoutAfterNextTimerIsDue1() {
promise.resolve();
}, 300);

const interval = setInterval(async () => {
await delay(400);
const interval = setInterval(() => {
Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, 400);
// Both the interval and the timeout's due times are now in the past.
clearInterval(interval);
}, 100);
Expand All @@ -255,7 +255,7 @@ Deno.test(async function clearTimeoutAfterNextTimerIsDue2() {
promise.resolve();
}, 200);

await delay(300);
Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, 300);
// Both of the timeouts' due times are now in the past.
clearTimeout(timeout1);

Expand Down