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

feat: async hooks and ESM #2522

Merged
merged 7 commits into from
Feb 29, 2024
Merged

feat: async hooks and ESM #2522

merged 7 commits into from
Feb 29, 2024

Conversation

hassy
Copy link
Member

@hassy hassy commented Feb 27, 2024

This PR add support for using async functions as hooks in HTTP and WebSocket engines, and the ability to load ES modules via config.processor.

Hooks:

  • beforeRequest, afterResponse, beforeScenario, afterScenario, and function hooks in the HTTP engine
  • function hook in the WebSocket engine

ESM:

  • If the extension of a processor file is .mjs, it will be import()'ed rather than require()'d.

  • Update to the docs needed
  • Changelog entry needed

Fixes #1269 #1384

Copy link

socket-security bot commented Feb 28, 2024

No dependency changes detected. Learn more about Socket for GitHub ↗︎

👍 No dependency changes detected in pull request

@hassy
Copy link
Member Author

hassy commented Feb 28, 2024

Not sure what's going on with Socket Security here - none of the dependencies it listed as new are in fact new other than detective-es6.

@hassy
Copy link
Member Author

hassy commented Feb 28, 2024

@SocketSecurity ignore-all

@hassy hassy changed the title feat: add support for async functions in HTTP and WebSocket engines feat: async hooks and ESM Feb 28, 2024
packages/core/lib/runner.js Show resolved Hide resolved
@bernardobridge
Copy link
Contributor

Also is it possible to add a test for the .mjs extension working?

@hassy
Copy link
Member Author

hassy commented Feb 29, 2024

Yep, tests to be added.

@bernardobridge
Copy link
Contributor

@hassy

FYI, was touching that part of the code to fix something else, so added ESM modules to the VS Code Extension schema already: 0e85c5b

We can merge that when this is merged.

* Update signatures of async hooks
* Remove check for exit code

Throwing from an async hook is the equivalent of calling the done()
callback with an Error object in a callback-based hook. The error
is shown as an entry in the metric report, and does not stop the
entire Artillery process.
The test is not checking the stacktraces as described. Would require
intercepting the error object at the point it gets tracked via
a metric - not straightforward.
@hassy hassy merged commit c2d53ba into main Feb 29, 2024
15 checks passed
@hassy hassy deleted the feat/async-hooks branch February 29, 2024 23:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support ES modules as processor
2 participants