Skip to content

Conversation

@nikneym
Copy link
Contributor

@nikneym nikneym commented Dec 24, 2025

This don't change the behavior for async and deferred scripts.

@nikneym nikneym added the zigdom label Dec 24, 2025
@nikneym nikneym requested a review from karlseguin December 24, 2025 11:35
log.debug(.browser, "executed script", .{ .src = url, .success = success, .on_load = script_element._on_load != null });
}

defer page.tick();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This'll run microtasks, scheduled tasks, and microtasks again, is that right?

Maybe it should just be:

    _ = self.scheduler.run() catch |err| {
        log.err(.page, "scheduler", .{ .err = err });
    };
    self.js.runMicrotasks();

and remove page.tick.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that makes more sense. I thought running macrotasks after a script execution is necessary.

This don't change the behavior for async and deferred scripts.

just run microtasks after a script execution
@nikneym nikneym force-pushed the nikneym/script-execution-changes branch from cc7acb2 to b28ac8c Compare December 24, 2025 18:51

defer page.tick();
// We should run microtasks even if script execution fails.
defer page.js.runMicrotasks();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
defer page.js.runMicrotasks();
defer {
self.js.runMicrotasks();
_ = self.scheduler.run() catch |err| {
log.err(.page, "scheduler", .{ .err = err });
};
}

and you can remove the tick function from Page (I think)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants