Skip to content

Conversation

@karlseguin
Copy link
Collaborator

Currently, a timeout that sets a timeout can cause loop.run to block forever.

Also, cleanup URL stitch with leading './'. The resulting URL was valid, but since we use the URL as the module cache key, it's important to resolve various representations of the same URL in the same way.

Currently, a timeout that sets a timeout can cause loop.run to block forever.

Also, cleanup URL stitch with leading './'. The resulting URL was valid, but
since we use the URL as the module cache key, it's important to resolve various
representations of the same URL in the same way.
@karlseguin
Copy link
Collaborator Author

Initial version of this didn't work well.

The goal is to prevent this type of code:

function logEvents() {
   send(events);
   setTimeout(logEvents, 3000);

From making loop.run() run forever.

However, simply preventing timeouts from being registered during "shutdown" can break pages. For example, our fetch.js does this:

onload: function() {
  // ...
  setTimeout(function() {
    resolve(new Response(body, options));
  }, 0);
}

Which means that something like:

fetch(request).then((res) => {.....});

may not work if onload is called during loop.run (because we'll ignore the timeout to resolve the promise).

In other words, some timeouts we want to ignore, and some we don't. But I don't think we can tell which is why so, for now, I just added a timeout.

};

try page.wait();
try page.wait(std.time.ns_per_s * 3);
Copy link
Member

Choose a reason for hiding this comment

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

I guess we will like to set a user-facing option at some point.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

If we take a param, it should get used/passed to:

if (delay > 5000) {

I was thinking something a bit fancier. Accepting an arbitrary JS script, e.g. --eval "document.getElementbyId('comments')" which we run on every loop and, when it returns a truthy JS value, we exit.

@karlseguin karlseguin merged commit a00c234 into main Jun 24, 2025
11 checks passed
@karlseguin karlseguin deleted the endless_loop_fix_and_dot_slash_stitch branch June 24, 2025 00:58
@github-actions github-actions bot locked and limited conversation to collaborators Jun 24, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants