Skip to content

Commit 2ef3deb

Browse files
committed
chore(content): added common errors
1 parent 227fc63 commit 2ef3deb

File tree

9 files changed

+92
-9
lines changed

9 files changed

+92
-9
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ docker compose exec utility-bot ./utility-bot discord:invite
6262
- Registered slash commands can be removed by `discord:clean` command.
6363
- Only one sub-command level is supported; for example, `foo bar` is valid.
6464
- Markdown content
65-
- Content within the slash commands can have a maximum of 3500 characters.
65+
- Content within the slash commands can have a maximum of 2000 characters.
6666
- The bot will cache Markdown content on memory to avoid spamming I/O.
6767
- Moderators
6868
- They can be defined by their unique Discord ID in `config.yml`.

cmd/content/validate.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,15 @@ import (
1010
var Validate = &cobra.Command{
1111
Use: "content:validate",
1212
Short: "Validates the Markdown content in the configuration to be the correct length",
13-
RunE: func(cmd *cobra.Command, args []string) error {
13+
Run: func(cmd *cobra.Command, args []string) {
1414
err := cache.Content()
1515
if err != nil {
16-
return err
16+
log.Fatal().Err(err).Send()
17+
return
1718
}
1819

1920
log.Info().
2021
Int("content-validated", len(config.GetConfig().Commands)).
2122
Msg("Good job! everything looks fine :)")
22-
23-
return nil
2423
},
2524
}

config.yml

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,11 @@ commands:
6969
# Protected commands
7070
# Only users with "Manage Messages" permission can _see_ and _use_ these commands.
7171
#
72+
mods cross-post:
73+
description: "Don't cross post, ask in relevant channels, be patient and structure your question"
74+
content: "./content/mods/cross-post.md"
75+
protected: true
76+
7277
mods spam:
7378
description: "A friendly warning to prevent spamming in the chat"
7479
content: "./content/mods/spam.md"
@@ -109,24 +114,61 @@ commands:
109114
url: "https://trilon.io/blog/avoiding-circular-dependencies-in-nestjs"
110115
emoji: "📝"
111116

117+
docs file-change-detected:
118+
description: "How to fix when TypeScript 4.9+ on Windows causes infinite loop in watch mode"
119+
content: "./content/docs/file-change-detected.md"
120+
buttons:
121+
-
122+
- label: "TypeScript documentation"
123+
url: "https://www.typescriptlang.org/tsconfig#watch-watchDirectory"
124+
emoji: "🔗"
125+
-
126+
- label: "New strategy for detecting file changes"
127+
url: "https://devblogs.microsoft.com/typescript/announcing-typescript-4-9/#file-watching-now-uses-file-system-events"
128+
emoji: "📝"
129+
112130
docs hybrid-app:
113-
description: "Create hybrid apps with Nest.js and microservices"
131+
description: "Create hybrid apps with NestJS and microservices"
114132
content: "./content/docs/hybrid-app.md"
115133
buttons:
116134
-
117135
- label: "Read more"
118136
url: "https://docs.nestjs.com/faq/hybrid-application"
119137
emoji: "🔗"
120138

139+
docs nest-debug:
140+
description: "Debug NestJS dependencies with environment variable"
141+
content: "./content/docs/nest-debug.md"
142+
121143
docs request-lifecycle:
122-
description: "Get a grip on Nest.js' request lifecycle for smooth coding"
144+
description: "Get a grip on NestJS' request lifecycle for smooth coding"
123145
content: "./content/docs/request-lifecycle.md"
124146
buttons:
125147
-
126148
- label: "Read more"
127149
url: "https://docs.nestjs.com/faq/request-lifecycle"
128150
emoji: "🔗"
129151

152+
docs resolve-dependencies:
153+
description: "Nest not being able to resolve dependencies of something"
154+
content: "./content/docs/resolve-dependencies.md"
155+
buttons:
156+
-
157+
- label: "Read more about this error"
158+
url: "https://docs.nestjs.com/faq/common-errors#cannot-resolve-dependency-error"
159+
emoji: "🔗"
160+
-
161+
- label: "Standard NestJS provider practices"
162+
url: "https://docs.nestjs.com/fundamentals/custom-providers#di-fundamentals"
163+
emoji: "🔗"
164+
-
165+
- label: "Circular dependency"
166+
url: "https://docs.nestjs.com/faq/common-errors#circular-dependency-error"
167+
emoji: "🔗"
168+
- label: "Custom providers"
169+
url: "https://docs.nestjs.com/fundamentals/custom-providers"
170+
emoji: "🔗"
171+
130172
rules dm:
131173
description: "Use server to get help on NestJS; don't DM other members."
132174
content: "./content/rules/dm.md"

content/docs/circular-dependency.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Nest cannot create the <module> instance.
55
The module at index [<index>] of the <module> "imports" array is undefined.
66
77
Potential causes:
8-
- A circular dependency between modules. Use forwardRef() to avoid it. Read more: https://docs.nestjs.com/fundamentals/circular-dependency
8+
- A circular dependency between modules. Use forwardRef() to avoid it.
99
- The module at index [<index>] is of type "undefined". Check your import statements and the type of the module.
1010
1111
Scope [<module_import_chain>]
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
Windows users who are using TypeScript version 4.9 and up may encounter this problem.
2+
This happens when you're trying to run your application in watch mode, e.g `npm run start:dev` and see an endless loop of the log messages:
3+
```text
4+
XX:XX:XX AM - File change detected. Starting incremental compilation...
5+
XX:XX:XX AM - Found 0 errors. Watching for file changes.
6+
```
7+
When you're using the NestJS CLI to start your application in watch mode it is done by calling `tsc --watch`, and as of version 4.9 of TypeScript, a new strategy for detecting file changes is used which is likely to be the cause of this problem.
8+
In order to fix this problem, you need to add a setting to your tsconfig.json file after the `"compilerOptions"` option as follows:
9+
```json
10+
{
11+
"watchOptions": {
12+
"watchFile": "fixedPollingInterval"
13+
}
14+
}
15+
```
16+
This tells TypeScript to use the polling method for checking for file changes instead of file system events (the new default method), which can cause issues on some machines.
17+
You can read more about the `"watchFile"` option in TypeScript documentation.

content/docs/nest-debug.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Along with just manually verifying your dependencies are correct, as of Nest 8.1.0 you can set the `NEST_DEBUG` environment variable to a string that resolves as truthy, and get extra logging information while Nest is resolving all the dependencies for the application.
2+
https://docs.nestjs.com/assets/injector_logs.png
3+
The string in yellow is the host class of the dependency being injected, the string in blue is the name of the injected dependency, or its injection token, and the string in purple is the module in which the dependency is being searched for. Using this, you can usually trace back the dependency resolution for what's happening and why you're getting dependency injection problems.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
The most common error in Nest is failing to resolve provider dependencies.
2+
The error message usually looks something like this:
3+
```text
4+
Nest can't resolve dependencies of the <provider> (?). Please make sure that the argument <unknown_token> at index [<index>] is available in the <module> context.
5+
6+
Potential solutions:
7+
- Is <module> a valid NestJS module?
8+
- If <unknown_token> is a provider, is it part of the current <module>?
9+
- If <unknown_token> is exported from a separate @Module, is that module imported within <module>?
10+
@Module({
11+
imports: [ /* the Module containing <unknown_token> */ ]
12+
})
13+
```
14+
The most common culprit of the error, is not having the `<provider>` in the module's `providers` array.
15+
Please make sure that the provider is indeed in the `providers` array and following standard NestJS provider practices.
16+
17+
There are a few gotchas, that are common. One is putting a provider in an `imports` array.
18+
If this is the case, the error will have the provider's name where `<module>` should be.

content/mods/cross-post.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
**Please do not cross post.**
2+
Please refrain from posting your question in multiple channels, or linking the channel elsewhere.
3+
If someone knew topic A, they would be in the topic A channel. Asking in irrelevant channels is just spam.
4+
Please be patient waiting for an answer, it may take time for someone with adequate knowledge to answer your question, furthermore, make sure that your question is well-structured.

core/cache/content.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111

1212
// Content will cache local Markdown content on memory
1313
func Content() error {
14-
charLimit := 3500
14+
charLimit := 2000
1515

1616
for _, c := range config.GetConfig().Commands {
1717
// Ignore non markdown files

0 commit comments

Comments
 (0)