Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save thecodermehedi/646524977d1a6b7d3f80a7b664180f8d to your computer and use it in GitHub Desktop.
Save thecodermehedi/646524977d1a6b7d3f80a7b664180f8d to your computer and use it in GitHub Desktop.
TypeError: Cannot read properties of undefined (reading 'headersSent')

it wasn't a problem with Express, but an issue with my coding style. Because I don't use semicolons the error ocurred.

app.use(...)

(async () => {
   ...
})()

The code gets transpiled as the app.use(...) returns a fn, that the async fn will init, so what I did was adding a semicolon before the async fn so the code would look like this:

app.use(...)

;(async () => {
   ...
})()

orginal issue discussion

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment