fastify-schedule icon indicating copy to clipboard operation
fastify-schedule copied to clipboard

docs(readme): use `after()` over `ready()` in example

Open hungnb94 opened this issue 11 months ago • 4 comments

This PR addresses an issue where using the ready method causes the application to get stuck when running unit tests. To resolve this, the after method is used instead, ensuring that the necessary logic is executed without blocking the test execution. Changes:

Replaced `ready` method with `after` to prevent test execution from getting stuck.

Reason for Change:

The `ready` method can introduce unexpected behavior in unit test environments, leading to tests hanging indefinitely.
The `after` method ensures the required logic is executed after initialization without interfering with test execution.

Testing:

Ran unit tests successfully without any hanging issues.
Verified the functionality remains unchanged in the main application.

hungnb94 avatar Feb 16 '25 06:02 hungnb94

There is also wrong variable name in the example. Should be:

-fastify.register(fastifySchedulePlugin);
+fastify.register(fastifySchedule);

DmitryScaletta avatar Feb 23 '25 16:02 DmitryScaletta

There is also wrong variable name in the example. Should be:

-fastify.register(fastifySchedulePlugin);
+fastify.register(fastifySchedule);

You're right. I'm going to update PR now.

hungnb94 avatar Feb 23 '25 23:02 hungnb94

@hungnb94, the unit tests in this repo use ready() and they appear okay. Could you clarify on the issue, maybe with an example? Thanks!

Fdawgs avatar Feb 27 '25 10:02 Fdawgs

@hungnb94, the unit tests in this repo use ready() and they appear okay. Could you clarify on the issue, maybe with an example? Thanks!

You can check branch dev here: https://github.com/hungnb94/fastify-demo/tree/dev I think the problem related to AutoLoad feature

hungnb94 avatar Feb 28 '25 11:02 hungnb94