Skip to content

Commit

Permalink
Add explicit Koa error handler
Browse files Browse the repository at this point in the history
This is what the documentation suggests, it seems errors
are swallowed otherwise.
  • Loading branch information
backspace committed Mar 9, 2024
1 parent 3c43cbb commit 557188f
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions packages/realm-server/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import './lib/externals';
import { nodeStreamToText } from './stream';
import mime from 'mime-types';
import { extractSupportedMimeType } from '@cardstack/runtime-common/router';
import * as Sentry from '@sentry/node';

interface Options {
assetsURL?: URL;
Expand Down Expand Up @@ -96,6 +97,13 @@ export class RealmServer {
.use(router.routes())
.use(this.serveFromRealm);

app.on('error', (err, ctx) => {
Sentry.withScope((scope) => {
scope.setSDKProcessingMetadata({ request: ctx.request });
Sentry.captureException(err);
});
});

return app;
}

Expand Down

0 comments on commit 557188f

Please sign in to comment.