Skip to content

feat: introduce waitFor #20

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

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

simone-sanfratello
Copy link
Contributor

@simone-sanfratello simone-sanfratello commented Feb 20, 2025

I'm proposing to introduce a waitFor method, as it is a very useful way to wait for a specific log message as it was an event, see this test case as an example https://github.com/fastify/fastify-http-proxy/pull/405/files#diff-b59655a410d4b510490ef7061e70dfd99b3f0b95473c0300376ff7c918d47d73R299

est('should call onDisconnect hook', async (t) => {
  const onDisconnect = () => {
    logger.info('onDisconnect called')
  }

  const wsReconnectOptions = {
    logs: true,
  }

  const { loggerSpy, logger, client } = await createServices({ t, wsReconnectOptions, wsHooks: { onDisconnect } })
  client.close()

  await waitForLogMessage(loggerSpy, 'onDisconnect called')
})

If you agree on it, I'm going for the implementation

@mcollina
Copy link
Member

This would be a great idea, +1

@simone-sanfratello
Copy link
Contributor Author

Cool, in this way we can get rid of plan

@simone-sanfratello simone-sanfratello marked this pull request as draft March 12, 2025 12:36
@simone-sanfratello simone-sanfratello marked this pull request as ready for review March 12, 2025 13:02
@mcollina mcollina requested a review from jsumners March 12, 2025 13:42
@simone-sanfratello simone-sanfratello marked this pull request as draft March 13, 2025 08:53
@simone-sanfratello
Copy link
Contributor Author

I need to update the design, it does not work properly with concurrent calls, because of the event listen is added and removed

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