Skip to content

Commit

Permalink
Catch transport errors when flushing session (#439)
Browse files Browse the repository at this point in the history
  • Loading branch information
timfish authored Mar 21, 2022
1 parent 4bf88db commit 24403ed
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 8 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

## 3.0.5

- fix: Issue where transport errors can prevent app exit

## 3.0.4

- fix: Use esModuleInterop for deepmerge (#432)
Expand All @@ -26,7 +30,9 @@
A large refactor and simplification of the SDK moving most of the functionality into integrations used with
`@sentry/browser` and `@sentry/node`.

- Session tracking data sent by default. See our [release health docs for more details](https://docs.sentry.io/product/releases/health/). You can opt out of this behaviour by setting `autoSessionTracking: false` during SDK initialization.
- Session tracking data sent by default. See our
[release health docs for more details](https://docs.sentry.io/product/releases/health/). You can opt out of this
behaviour by setting `autoSessionTracking: false` during SDK initialization.
- Performance monitoring of renderer instances using the `BrowserTracing` integration from `@sentry/tracing`
- Preload script no longer required [for most scenarios](https://github.com/getsentry/sentry-electron/issues/376)
- Optional relative imports for main/renderer/preload entry points to help with bundlers
Expand Down
10 changes: 7 additions & 3 deletions src/main/integrations/main-process-session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,14 @@ export class MainProcessSession implements Integration {
// Stop the exit so we have time to send the session
event.preventDefault();

// End the session
await endSession();
try {
// End the session
await endSession();
} catch (e) {
// Ignore and log any errors which would prevent app exit
logger.log('[MainProcessSession] Error ending session', e);
}

// After flush we can safely exit
app.exit();
};
}
2 changes: 1 addition & 1 deletion src/main/transports/electron-offline-net.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export class ElectronOfflineNetTransport extends ElectronNetTransport {
this._requestSuccess();
return response;
} catch (error) {
if (error instanceof HTTPError && error.status != 'rate_limit') {
if (error instanceof HTTPError && error.status !== 'rate_limit') {
logger.log('Dropping request');
// We don't queue HTTP errors that are not rate limited
throw error;
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { inspect } from 'util';
import { eventIsSession } from '../recipe';
import { createLogger } from '../utils';

import { parse_multipart, sentryEventFromFormFields } from './multi-part';
import { parseMultipart, sentryEventFromFormFields } from './multi-part';

const log = createLogger('Test Server');

Expand Down Expand Up @@ -106,7 +106,7 @@ export class TestServer {
return;
}

const result = await parse_multipart(ctx);
const result = await parseMultipart(ctx);
const [event, namespacedData] = sentryEventFromFormFields(result);
const dumpFile = result.files.upload_file_minidump != undefined && result.files.upload_file_minidump > 1024;

Expand Down
2 changes: 1 addition & 1 deletion test/e2e/server/multi-part.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export interface MultipartResult {
files: { [key: string]: number };
}

export function parse_multipart(
export function parseMultipart(
ctx: Koa.ParameterizedContext<any, Router.IRouterParamContext<any, any>, any>,
): Promise<MultipartResult> {
return new Promise((resolve) => {
Expand Down

0 comments on commit 24403ed

Please sign in to comment.