-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Labels
Meta: Help WantedPackage: nodeIssues related to the Sentry Node SDKIssues related to the Sentry Node SDK
Description
- Review the documentation: https://docs.sentry.io/
- Search for existing issues: https://github.com/getsentry/sentry-javascript/issues
- Use the latest release: https://github.com/getsentry/sentry-javascript/releases
- Provide a link to the affected event from your Sentry account
Package + Version
-
@sentry/browser
-
@sentry/node
-
raven-js
-
raven-node
(raven for node) - other:
Version:
6.17.5
Description
This affects a complicated setup that I can't provide reproduction for easily.
The setup is:
- and express backend with
express-session
middleware running - custom session store that retrieves and stores session in a DynamoDB database and uses
AmazonDaxClient
for DB operations
Steps are:
- navigate to express route that just returns some data
res.json('OK')
- The
express-middleware
reads the session before handling the route and tries to save it onres.end()
(whichexpress-session
wraps) - When the saving of the session fails the dax client emits an
error
event:
- The emitted event seems to get handled by Sentry itself in the code linked below, resulting in the next
express
middleware running, even though the previous one has already responded to the request:
sentry-javascript/packages/node/src/handlers.ts
Lines 393 to 416 in a79c097
} return function sentryRequestMiddleware( req: http.IncomingMessage, res: http.ServerResponse, next: (error?: any) => void, ): void { if (options && options.flushTimeout && options.flushTimeout > 0) { // eslint-disable-next-line @typescript-eslint/unbound-method const _end = res.end; res.end = function (chunk?: any | (() => void), encoding?: string | (() => void), cb?: () => void): void { void flush(options.flushTimeout) .then(() => { _end.call(this, chunk, encoding, cb); }) .then(null, e => { logger.error(e); }); }; } const local = domain.create(); local.add(req); local.add(res); local.on('error', next); - The difference with and without Sentry is that
this.domain
is not defined in the code below when Sentry is not used
When the issue triggers then we are getting the ERR_HTTP_HEADERS_SENT
error from Node because some later error middleware runs even though we've responded already.
Metadata
Metadata
Assignees
Labels
Meta: Help WantedPackage: nodeIssues related to the Sentry Node SDKIssues related to the Sentry Node SDK