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

Handler.close() exits parent process #370

Closed
claabs opened this issue Nov 8, 2021 · 0 comments
Closed

Handler.close() exits parent process #370

claabs opened this issue Nov 8, 2021 · 0 comments

Comments

@claabs
Copy link

claabs commented Nov 8, 2021

Following up on some discussion in the Discord server.

Calling handler.close() after creating an Agent will exit the process without any errors thrown.

Here's a simple reproduction that demonstrates the issue (running local core):

async function main(): Promise<void> {
  const handler = new Handler();
  const agent = await handler.createAgent();
  await agent.close();
  await handler.close();
  console.log('This should log');
}

main()
  .then(() => console.log('finished'))
  .catch((err) => console.error(err));

This should log does not get logged

This also occurs with dispatchAgent:

async function main2(): Promise<void> {
  const handler = new Handler();
  handler.dispatchAgent(async (agent) => {
    await agent.goto('https://example.com');
  });
  await handler.waitForAllDispatches();
  await handler.close();
  console.log('This should log');
}

main2()
  .then(() => console.log('finished'))
  .catch((err) => console.error(err));

Removing await handler.close() just causes the process to complete, but hang and not exit.

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

No branches or pull requests

2 participants