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

register a timeout in AbortSignal.any test #39879

Closed
wants to merge 2 commits into from

Conversation

panva
Copy link
Contributor

@panva panva commented May 7, 2023

Refs: nodejs/node#47821 (comment)

Because of the (i assume) weak references this test causes the Node.js worker that executes the suite to exit before this one runs to completion.

This change makes it so that a timeout is registered that should never be reached whilst still testing the combinedSignal behaviours when triggered by AbortSignal.timeout whilst keeping our test execution worker alive.

Refs:  nodejs/node#47821 (comment)

Because of the (i assume) weak references this test doesn't cause the Node.js worker that executes the tests to emit result and therefore completion of the suite.

This change makes it so that a timeout is registered that should never be reached whilst still testing the combinedSignal behaviours.
@annevk
Copy link
Member

annevk commented May 8, 2023

cc @shaseley

@shaseley
Copy link
Contributor

I'm curious why this would be needed here but not in the AbortSignal.timeout() tests? How does the test execution stay alive for those tests?

@panva
Copy link
Contributor Author

panva commented May 10, 2023

I'm curious why this would be needed here but not in the AbortSignal.timeout() tests? How does the test execution stay alive for those tests?

There just needs to be one that covers the duration of the other tests? 🤷‍♂️

I don't have the time to invest in this and only wish to unblock node.js landing the feature.

Edit:

this test, particularly its use of step_timeout, in AbortSignal.any.js does the same for that file, when I comment the test out, our runner behaves the same.

async_test(t => {
  const s = AbortSignal.abort();
  s.addEventListener("abort", t.unreached_func("abort event listener called"));
  s.onabort = t.unreached_func("abort event handler called");
  t.step_timeout(() => { t.done(); }, 2000);
}, "signal returned by AbortSignal.abort() should not fire abort event");

@panva
Copy link
Contributor Author

panva commented May 14, 2023

Can we move this forward to unblock nodejs landing AbortSignal.any?

@annevk
Copy link
Member

annevk commented May 15, 2023

Hmm, it sounds like a bug that your engine doesn't run to completion here. I don't think we should add something that ends up hiding that.

@panva
Copy link
Contributor Author

panva commented May 15, 2023

That's not an accurate assessment. The event loop has nothing to process and is finished, worker process exits. Other AbortSignal tests have a timeout in them too.

This addition does not alter the tested behaviour so please reconsider.

@annevk
Copy link
Member

annevk commented May 15, 2023

But there is something to process, no? The abort listener?

@panva
Copy link
Contributor Author

panva commented May 15, 2023

I'm not that into the abortsignal spec but I find it strange that e.g. abortsignal.timeout would hang a process when passed to a fetch which has already finished.

@panva
Copy link
Contributor Author

panva commented May 15, 2023

I'd hate to have to go back to the nodejs wpt worker and register global timeouts there just because the tests are written primarily for browsers that sit on a test url until completion or timeout.

@annevk
Copy link
Member

annevk commented May 15, 2023

Well that is not the scenario here. Here we have a signal with an active listener.

@aduh95
Copy link

aduh95 commented May 15, 2023

Here we have a signal with an active listener.

I'm not sure I understand what active listener means in this context, are you saying that e.g. having new AbortController().signal.onabort = () => {}; somewhere in the code base should make the process hang forever? That would not be my expectation, and be quite surprising actually 🤔 Is there something in the spec that defines this or is it up to implementers?

@annevk
Copy link
Member

annevk commented May 15, 2023

That's a good question, it depends on how you define your event loop.

Looking at the one the HTML Standard defines for workers, I'm not sure how this PR ends up helping as the task queue would still be empty. Hmm. (Though for workers you do need to close it first, which doesn't happen fully automatically.)

(There's no difference in that respect between setTimeout() and AbortSignal.timeout().)

@panva panva closed this May 17, 2023
@panva panva deleted the patch-1 branch May 23, 2023 18:52
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.

None yet

6 participants