Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(sentry): wait for the right amount of time. #391

Merged
merged 1 commit into from
Aug 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import log from './log.js';
import datadog from './datadog.js';
import * as jsDelivr from './jsDelivr/index.js';
import * as sentry from './utils/sentry.js';
import wait from './utils/wait.js';

log.info('🗿 npm ↔️ Algolia replication starts ⛷ 🐌 🛰');

Expand Down Expand Up @@ -328,9 +327,6 @@ async function watch(stateManager, mainIndex) {

async function error(err) {
sentry.report(err);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can pass more info here wrt the json problem, but I couldn't find where to get the original json


// Wait for sentry to report the error on their API
await wait(5000);

await sentry.drain();
process.exit(1); // eslint-disable-line no-process-exit
}
10 changes: 8 additions & 2 deletions src/utils/sentry.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Sentry.init({
serverName: 'npm-search',
});

function report(err, extra = {}) {
export function report(err, extra = {}) {
log.error(err.message);
if (!process.env.SENTRY_DSN) {
log.error(err);
Expand All @@ -22,4 +22,10 @@ function report(err, extra = {}) {
});
}

export { report };
export function drain() {
const client = Sentry.getCurrentHub().getClient();
if (client) {
return client.close(2000);
}
return Promise.resolve();
}
7 changes: 0 additions & 7 deletions src/utils/wait.js

This file was deleted.