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: add return after making server response #2074

Merged
merged 1 commit into from
Dec 7, 2022

Conversation

halfwhole
Copy link
Collaborator

@halfwhole halfwhole commented Nov 10, 2022

Problem

In two places in the codebase, the server does not return immediately after making a response, leading to res.send() being called twice, which causes an unhandled promise rejection. This is still okay for node <14 because it just gives a warning, but not from node 15 onwards (see node 15 release docs) as it throws an error and terminates the entire node process, which is very scary.

Example error message:
Screenshot 2022-11-10 at 6 26 35 PM

Solution

  • In UserController: simply add return
  • In LinkAuditController: had to invert the logic a little to do the same functionality without calling res.send() twice

Copy link
Contributor

@gweiying gweiying left a comment

Choose a reason for hiding this comment

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

lgtm

@halfwhole halfwhole merged commit d36c6f3 into develop Dec 7, 2022
@halfwhole halfwhole deleted the fix/return-after-response branch December 7, 2022 08:37
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