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

fix: zero coercion timeout removal bug #72

Merged
merged 1 commit into from
Jun 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion builtins/web/timers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ class TimerTask final : public api::AsyncTask {
};

std::map<int32_t, PollableHandle> TimerTask::timer_ids_ = {};
int32_t TimerTask::next_timer_id = 0;
int32_t TimerTask::next_timer_id = 1;

namespace builtins::web::timers {

Expand Down
10 changes: 10 additions & 0 deletions tests/integration/timers/timers.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@ import { serveTest } from "../test-server.js";
import { assert, strictEqual, throws, deepStrictEqual, AssertionError } from "../assert.js";

export const handler = serveTest(async (t) => {
await t.asyncTest("clearTimeout invalid", (resolve, reject) => {
// cleartimeout can be called with arbitrary stuff
clearTimeout('blah');

const dontDeleteTimeout = setTimeout(resolve, 100);

// null converts to zero, which must not delete a real timer
clearTimeout(null);
});

await t.asyncTest("setTimeout-order", (resolve, reject) => {
let first = false;
setTimeout(() => {
Expand Down
Loading