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

(JS-0116) async function should have await expression #4

Closed
whitlocktech opened this issue May 28, 2023 · 0 comments · Fixed by #8
Closed

(JS-0116) async function should have await expression #4

whitlocktech opened this issue May 28, 2023 · 0 comments · Fixed by #8
Labels
bug Something isn't working
Milestone

Comments

@whitlocktech
Copy link
Owner

whitlocktech commented May 28, 2023

Description

A function that does not contain any await expressions should not be async (except for some edge cases in TypeScript which are discussed below). Asynchronous functions in JavaScript behave differently than other functions in two important ways:

Occurrences

const server = http.createServer(app)

async function startServer() {
  server.listen(PORT, () => {
    mongoConnect()
    console.log(`Server is running on port ${PORT}`)
  })
}

startServer()
  console.error('Mongoose Connection Error', err)
})

async function mongoConnect() {
  mongoose.connect(MONGO_URL)
}

async function mongoDisconnect() { 
  await mongoose.disconnect()
@whitlocktech whitlocktech added the bug Something isn't working label May 28, 2023
@whitlocktech whitlocktech added this to the 1.0.1 milestone May 28, 2023
@whitlocktech whitlocktech linked a pull request May 28, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant