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

AVA unhandled exceptions patch should be accomplished in userspace #11028

Open
michaelfig opened this issue Feb 20, 2025 · 1 comment
Open

AVA unhandled exceptions patch should be accomplished in userspace #11028

michaelfig opened this issue Feb 20, 2025 · 1 comment
Assignees
Labels
enhancement New feature or request test

Comments

@michaelfig
Copy link
Member

michaelfig commented Feb 20, 2025

What is the Problem Being Solved?

agoric-sdk/packages/internal/src/lib-nodejs/ava-unhandled-rejection.js uses a subprocess and agoric-sdk/patches/ava+5.3.1.patch to isolate the test and then be able to expect a count of how many unhandled rejections it creates without crashing AVA.

Description of the Design

While the subprocess is still a good idea to prevent cross-contamination of unhandled rejections, @gibson042 had suggestions for how the subprocess could use the process.on events to count and handle rejections.

We could adopt the same algorithm from SES for unhandled rejections (only marking a rejection as unhandled upon GC of the Promise). That way, the tests won't be sensitive to the SES configuration itself.

This would be a modification just to the internals of ava-unhandled-rejection.js.

Security Considerations

Test code only.

Scaling Considerations

n/a

Test Plan

The point.

Upgrade Considerations

None.

@michaelfig michaelfig added the enhancement New feature or request label Feb 20, 2025
@michaelfig
Copy link
Member Author

From @gibson042 : fail the test if an unhandled rejection doesn't happen

  const unhandled = new Set();
  const onUnhandled = (_reason, p) => {
    unhandled.add(p);
  };
  const onHandledLate = p => {
    unhandled.delete(p);
  };
  process.on('unhandledRejection', onUnhandled);
  process.on('rejectionHandled', onHandledLate);
  t.teardown(() => {
    process.off('unhandledRejection', onUnhandled);
    process.off('rejectionHandled', onHandledLate);
  });

  // …remainder of test body…

  t.true(unhandled.size > 0);

@michaelfig michaelfig self-assigned this Feb 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request test
Projects
None yet
Development

No branches or pull requests

1 participant