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

fix: application shutdown #536

Conversation

DecathectZero
Copy link

@DecathectZero DecathectZero commented Nov 5, 2023

PR Checklist

Please check if your PR fulfills the following requirements:

  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

PR Type

What kind of change does this PR introduce?

  • [ x ] Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Other... Please describe:

What is the current behavior?

Currently when my app has enableShutdownHooks it will fail every time because of:

.../node_modules/@nestjs/core/injector/instance-links-host.js:24
            throw new unknown_element_exception_1.UnknownElementException(this.getInstanceNameByToken(token));
                  ^

Error: Nest could not find Symbol() element (this provider does not exist in the current context)
    at InstanceLinksHost.get (.../node_modules/@nestjs/core/injector/instance-links-host.js:24:19)
    at Object.find (.../node_modules/@nestjs/core/injector/abstract-instance-resolver.js:8:60)
    at Object.get (.../node_modules/@nestjs/core/injector/module.js:399:29)
    at RedisModule2.onApplicationShutdown (.../node_modules/@liaoliaots/nestjs-redis/dist/redis/redis.module.js:68:48)
    at callAppShutdownHook (.../node_modules/@nestjs/core/hooks/on-app-shutdown.hook.js:51:35)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at NestApplication.callShutdownHook (.../node_modules/@nestjs/core/nest-application-context.js:254:13)
    at process.cleanup (.../node_modules/@nestjs/core/nest-application-context.js:191:17)

Digging through the NestJS source code and logging all the issues, this:
https://github.com/nestjs/nest/blob/master/packages/core/injector/module.ts#L611-L615
the self.id NEVER matches up with the ID of whatever
this.moduleRef.get<RedisModuleOptions>(REDIS_MERGED_OPTIONS)
or this.moduleRef.get<RedisClients>(REDIS_CLIENTS) is.

This check always fails:
https://github.com/nestjs/nest/blob/master/packages/core/injector/instance-links-host.ts#L44-L46

This PR also address and fixes this issue:
#335

Issue Number: N/A

What is the new behavior?

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

@liaoliaots
Copy link
Owner

Please check out the new version: version 10 of @liaoliaots/nestjs-redis.

@liaoliaots liaoliaots closed this Sep 25, 2024
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