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

Resolver.add throwing Error could break in some Hot Reloaders #24

Open
josemarcilio opened this issue Feb 5, 2024 · 1 comment
Open

Comments

@josemarcilio
Copy link

josemarcilio commented Feb 5, 2024

Currently I'm experimenting Mediatr TS with Remix, and I think I got a problem with Hot Reload. I receive:

Error: The key GetFilterableMakesCommand is already been added
    at Resolver.add (file:///home/zbradev06/Source/cars/node_modules/.pnpm/mediatr-ts@1.2.1/node_modules/mediatr-ts/src/models/resolver.ts:45:20)

for my decorated class:

@requestHandler(GetFilterableMakesCommand)
export class GetFilterableMakesCommandHandler {}

for each code update and hot reload. It works perfectly using the app normally.

IMHO throwing here is unnecessary. I think there's no reason to break the program for an already registered RequestHandler, especially if we can´t catch this error with a good experience.

I am using pnpm so I can patch locally, and I'll change the throw for a console.error or some similar solution.

Also I can open a PR with this change if this is an acceptable solution for the project.

@m4ss1m0g
Copy link
Owner

Try to write the necessary code and the relative unit tests, then open a PR.
Thanks.

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