Skip to content

Commit

Permalink
fixup! actor alarms tests: Reject waiting promise on alarm handler ex…
Browse files Browse the repository at this point in the history
…ception
  • Loading branch information
jclee committed Sep 17, 2024
1 parent 5a8ac6b commit d2417f9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
9 changes: 4 additions & 5 deletions src/workerd/api/actor-alarms-delete-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,12 @@ export class DurableObjectExample {

async waitForAlarm(scheduledTime) {
let self = this;
let prom = new Promise((resolve, reject) => {
self.resolve = resolve;
self.reject = reject;
});
const { promise, resolve, reject } = Promise.withResolvers();
self.resolve = resolve;
self.reject = reject;

try {
await prom;
await promise;
if (Date.now() < scheduledTime.valueOf()) {
throw new Error(
`Date.now() is before scheduledTime! ${Date.now()} vs ${scheduledTime.valueOf()}`
Expand Down
9 changes: 4 additions & 5 deletions src/workerd/api/actor-alarms-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,12 @@ export class DurableObjectExample {

async waitForAlarm(scheduledTime) {
let self = this;
let prom = new Promise((resolve, reject) => {
self.resolve = resolve;
self.reject = reject;
});
const { promise, resolve, reject } = Promise.withResolvers();
self.resolve = resolve;
self.reject = reject;

try {
await prom;
await promise;
if (Date.now() < scheduledTime.valueOf()) {
throw new Error(
`Date.now() is before scheduledTime! ${Date.now()} vs ${scheduledTime.valueOf()}`
Expand Down

0 comments on commit d2417f9

Please sign in to comment.