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(server): fixed the error of repeatedly deleting website routes #957

Merged
merged 1 commit into from
Mar 24, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion server/src/gateway/website-task.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,6 @@ export class WebsiteTaskService {
// delete website route if exists
const route = await this.apisixService.getRoute(region, site._id.toString())
if (route) {
await this.apisixService.deleteWebsiteRoute(region, site)
const res = await this.apisixService.deleteWebsiteRoute(region, site)
this.logger.log(`delete website route: ${res?.key}`)
this.logger.debug('delete website route', res)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

by looking at the code.

The code is trying to delete a website route in the ApisixService. The code first checks if the route exists, and if it does, it attempts to delete it using the deleteWebsiteRoute method. The result of this operation is then logged.

It looks like there is a bug risk in this code. The code tries to delete the route even if it doesn't exist. This could lead to errors or unexpected behavior. To fix this, we can add a check to make sure the route exists before attempting to delete it.

In addition, it looks like the code is trying to log the result of the deletion operation. However, the code is not properly checking if the result is successful or not. To make sure that only successful deletions are logged, we can add a check to the logging code to ensure the result was successful before logging it.

Expand Down