You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
importexpressfrom"express";import*asSentryfrom"@sentry/node";// or using CommonJS// const express = require('express');// const Sentry = require('@sentry/node');constapp=express();Sentry.init({dsn: "https://examplePublicKey@o0.ingest.sentry.io/0"});// The request handler must be the first middleware on the appapp.use(Sentry.Handlers.requestHandler());// All controllers should live hereapp.get("/",functionrootHandler(req,res){res.end("Hello world!");});// The error handler must be before any other error middleware and after all controllersapp.use(Sentry.Handlers.errorHandler());// Optional fallthrough error handlerapp.use(functiononError(err,req,res,next){// The error id is attached to `res.sentry` to be returned// and optionally displayed to the user for support.res.statusCode=500;res.end(res.sentry+"\n");});app.listen(3000);
The server can start successfully, however, if hit any endpoint such as going to http://localhost:3000 in this case, the server will crash with error
Package + Version
@sentry/browser
@sentry/node
raven-js
raven-node
(raven for node)Version:
Description
Use Node.js 16.2.0 (latest version writing this), and simply use the demo at
https://docs.sentry.io/platforms/node/guides/express/
The server can start successfully, however, if hit any endpoint such as going to http://localhost:3000 in this case, the server will crash with error
I located, without line
app.use(Sentry.Handlers.requestHandler());
, it won't have this issue.The text was updated successfully, but these errors were encountered: