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

Fix trap handling when running components #382

Merged
merged 2 commits into from
Jun 13, 2024
Merged

Conversation

elliottt
Copy link
Contributor

@elliottt elliottt commented Jun 11, 2024

The component implementation didn't have support for either the test-fatalerror-config feature, or the ability to treat the Error::FatalError variant as a trap. This PR fixes that by doing the following:

  • Allowing header_values_get to trap based on the test-fatalerror-config feature
  • Introducing the TrappableError type for treating FatalError as a trap
  • Adding a variant of the trap-test that uses the component adapter

The remaining difference to the wiggle implementation is that only functions listed in trappable_errors will be able to emit traps for FatalError, though the only case we currently use that in is for test-fatalerror-config, so it seemed reasonable to not switch everything to TrappableError.

@elliottt elliottt force-pushed the trevor/component-trap-test branch from 9dd8d53 to 3b35f22 Compare June 11, 2024 23:39
@elliottt elliottt marked this pull request as ready for review June 11, 2024 23:39
@elliottt elliottt requested review from athomason, acw and acfoltzer June 11, 2024 23:40
Copy link
Contributor

@acfoltzer acfoltzer left a comment

Choose a reason for hiding this comment

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

Looks good except for weird stray braces

Comment on lines +15 to +22

trappable_error_type: {
"fastly:api/types/error" => types::TrappableError,
},

trappable_imports: [
"header-values-get"
],
Copy link
Contributor

Choose a reason for hiding this comment

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

It's a little funky that these types will be different even in the non-trapping config, but I think this probably the lightest touch possible for making the two modes work out (vs duplicating the macro invocation entirely between both configs... ugh)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It also makes it so that we don't have to deal with nested Result values in the return type for header-values-get, which is much easier for me to think about 😅

lib/src/component/http_resp.rs Outdated Show resolved Hide resolved
@elliottt elliottt force-pushed the trevor/component-trap-test branch from 1459351 to 5bde097 Compare June 13, 2024 21:27
@elliottt elliottt requested a review from acfoltzer June 13, 2024 21:28
Copy link
Contributor

@acfoltzer acfoltzer left a comment

Choose a reason for hiding this comment

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

🪤

@elliottt elliottt merged commit b52af69 into main Jun 13, 2024
7 checks passed
@elliottt elliottt deleted the trevor/component-trap-test branch June 13, 2024 21:45
GeeWee pushed a commit to GeeWee/Viceroy that referenced this pull request Jul 25, 2024
The component implementation didn't have support for either the test-fatalerror-config feature, or the ability to treat the Error::FatalError variant as a trap. This PR fixes that by doing the following:

* Allowing header_values_get to trap based on the test-fatalerror-config feature
* Introducing the TrappableError type for treating FatalError as a trap
* Adding a variant of the trap-test that uses the component adapter

The remaining difference to the wiggle implementation is that only functions listed in trappable_errors will be able to emit traps for FatalError, though the only case we currently use that in is for test-fatalerror-config, so it seemed reasonable to not switch everything to TrappableError.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants