Skip to content

Commit 78285d7

Browse files
committed
fix tests
1 parent b6137b0 commit 78285d7

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

src/browser/page.zig

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,7 @@ pub const Page = struct {
321321
// store http_client.active BEFORE this call and then use
322322
// it AFTER.
323323
const ms_to_next_task = try scheduler.runHighPriority();
324+
_ = try scheduler.runLowPriority();
324325

325326
if (try_catch.hasCaught()) {
326327
const msg = (try try_catch.err(self.arena)) orelse "unknown";
@@ -329,7 +330,17 @@ pub const Page = struct {
329330
}
330331

331332
if (http_client.active == 0 and exit_when_done) {
332-
const ms = ms_to_next_task orelse {
333+
const ms = ms_to_next_task orelse blk: {
334+
// TODO: when jsRunner is fully replaced with the
335+
// htmlRunner, we can remove the first part of this
336+
// condition. jsRunner calls `page.wait` far too
337+
// often to enforce this.
338+
if (wait_ms > 100 and wait_ms - ms_remaining < 100) {
339+
// Look, we want to exit ASAP, but we don't want
340+
// to exit so fast that we've run none of the
341+
// background jobs.
342+
break :blk 50;
343+
}
333344
// no http transfers, no cdp extra socket, no
334345
// scheduled tasks, we're done.
335346
return .done;
@@ -341,7 +352,6 @@ pub const Page = struct {
341352
return .done;
342353
}
343354

344-
_ = try scheduler.runLowPriority();
345355
// we have a task to run in the not-so-distant future.
346356
// You might think we can just sleep until that task is
347357
// ready, but we should continue to run lowPriority tasks
@@ -353,7 +363,6 @@ pub const Page = struct {
353363
// We're here because we either have active HTTP
354364
// connections, of exit_when_done == false (aka, there's
355365
// an extra_socket registered with the http client).
356-
_ = try scheduler.runLowPriority();
357366
const ms_to_wait = @min(ms_remaining, ms_to_next_task orelse 100);
358367
if (try http_client.tick(ms_to_wait) == .extra_socket) {
359368
// data on a socket we aren't handling, return to caller

src/server.zig

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,6 @@ pub const Server = struct {
168168
ms_remaining = timeout_ms;
169169
},
170170
.done => {
171-
std.debug.print("ok\n", .{});
172171
const elapsed = timestamp() - last_message;
173172
if (elapsed > ms_remaining) {
174173
log.info(.app, "CDP timeout", .{});

src/testing.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ pub const JsRunner = struct {
424424
}
425425
return err;
426426
};
427-
self.page.session.wait(1000);
427+
_ = self.page.session.wait(100);
428428
@import("root").js_runner_duration += std.time.Instant.since(try std.time.Instant.now(), start);
429429

430430
if (case.@"1") |expected| {

0 commit comments

Comments
 (0)