Skip to content

test(e2e): Make proxy server more error resistant #11763

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

Merged
merged 2 commits into from
Apr 24, 2024
Merged
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
23 changes: 20 additions & 3 deletions dev-packages/event-proxy-server/src/event-proxy-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,11 @@ export async function startEventProxyServer(options: EventProxyServerOptions): P
});

proxyRequest.addListener('error', err => {
throw err;
// eslint-disable-next-line no-console
console.log('[event-proxy-server] Warn: Receiving proxy request errored!', err);
proxyResponse.writeHead(500);
proxyResponse.write('{}', 'utf-8');
proxyResponse.end();
});

proxyRequest.addListener('end', () => {
Expand All @@ -53,7 +57,16 @@ export async function startEventProxyServer(options: EventProxyServerOptions): P
const envelopeHeader: EnvelopeItem[0] = JSON.parse(proxyRequestBody.split('\n')[0]);

if (!envelopeHeader.dsn) {
throw new Error('[event-proxy-server] No dsn on envelope header. Please set tunnel option.');
// eslint-disable-next-line no-console
console.log(
'[event-proxy-server] Warn: No dsn on envelope header. Maybe a client-report was received. Proxy request body:',
proxyRequestBody,

Check warning

Code scanning / CodeQL

Log injection

Log entry depends on a [user-provided value](1).
);

proxyResponse.writeHead(200);
proxyResponse.write('{}', 'utf-8');
proxyResponse.end();
return;
}

const { origin, pathname, host } = new URL(envelopeHeader.dsn as string);
Expand Down Expand Up @@ -91,7 +104,11 @@ export async function startEventProxyServer(options: EventProxyServerOptions): P
});

sentryResponse.addListener('error', err => {
throw err;
// eslint-disable-next-line no-console
console.log('[event-proxy-server] Warn: Proxying to Sentry returned an error!', err);
proxyResponse.writeHead(500);
proxyResponse.write('{}', 'utf-8');
proxyResponse.end();
});

proxyResponse.writeHead(sentryResponse.statusCode || 500, sentryResponse.headers);
Expand Down