-
-
Notifications
You must be signed in to change notification settings - Fork 54
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
server: improve error message when client is not present #1242
Conversation
WalkthroughThe update to Changes
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review Status
Actionable comments generated: 1
Configuration used: CodeRabbit UI
Files selected for processing (1)
- server/app.ts (1 hunks)
Additional comments: 5
server/app.ts (5)
- 204-209: The addition of a specific warning message and a 404 error response when the client's distribution folder is not found is a good improvement for user experience.
- 204-209: The error message is clear and instructive, and the use of HTTP 404 is appropriate for the situation where the client files are not found. Ensure that this change does not interfere with any other routes that might be serving files or content from the
../client/dist
directory.Verification successful
The review comment's concern has been addressed. The server's existing functionality to serve static files from the
../client/dist
directory is conditional on the presence of the folder, and the new error handling logic only comes into play when the folder is missing. There should be no interference with existing routes as long as the client's distribution folder exists.* 204-209: No sensitive information is exposed in the new error message, and it does not introduce any security concerns. * 204-209: The file system check for the client's distribution folder is done only once during the server initialization, which is good for performance as it avoids repeated checks on each request. * 204-209: The new error handling for the missing client distribution folder is consistent with the application's error handling strategy, providing clear and actionable feedback to the user.Scripts Executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Verify that no other routes are serving content from the client's distribution folder. rg --type ts "express.static" --context 5 server/app.tsLength of output: 303
log.warn("no dist folder found, run `yarn build` to build the client"); | ||
app.get("*", (req, res) => { | ||
res.status(404).send( | ||
"File not found - Client files not found. Run `yarn build` to build the client." | ||
); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider abstracting the relative path to the client's distribution folder and the error message into configuration settings or constants to improve maintainability and avoid duplication.
- log.warn("no dist folder found, run `yarn build` to build the client");
- res.status(404).send(
- "File not found - Client files not found. Run `yarn build` to build the client."
- );
+ const clientDistPath = "../client/dist";
+ const buildClientMessage = "File not found - Client files not found. Run `yarn build` to build the client.";
+ log.warn(`no ${clientDistPath} folder found, run \`yarn build\` to build the client`);
+ res.status(404).send(buildClientMessage);
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
log.warn("no dist folder found, run `yarn build` to build the client"); | |
app.get("*", (req, res) => { | |
res.status(404).send( | |
"File not found - Client files not found. Run `yarn build` to build the client." | |
); | |
}); | |
const clientDistPath = "../client/dist"; | |
const buildClientMessage = "File not found - Client files not found. Run `yarn build` to build the client."; | |
log.warn(`no ${clientDistPath} folder found, run \`yarn build\` to build the client`); | |
app.get("*", (req, res) => { | |
res.status(404).send(buildClientMessage); | |
}); |
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## master #1242 +/- ##
===============================================
+ Coverage 0 61.5425% +61.5425%
===============================================
Files 0 117 +117
Lines 0 9413 +9413
Branches 0 1155 +1155
===============================================
+ Hits 0 5793 +5793
- Misses 0 3620 +3620 ☔ View full report in Codecov by Sentry. |
Passing run #846 ↗︎
Details:
Review all test suite changes for PR #1242 ↗︎ |
No description provided.