Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit ea0ba59

Browse files
committed
cursor & seer review
1 parent ab7bb77 commit ea0ba59

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

‎packages/aws-serverless/src/lambda-extension/aws-lambda-extension.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,15 +101,15 @@ export class AwsLambdaExtension {
101101
*/
102102
public startSentryTunnel(): void {
103103
const server = http.createServer(async (req, res) => {
104-
if (req.url?.startsWith('/envelope')) {
104+
if (req.method==='POST'&&req.url?.startsWith('/envelope')) {
105105
try {
106106
const buf = await buffer(req);
107107
// Extract the actual bytes from the Buffer by slicing its underlying ArrayBuffer
108108
// This ensures we get only the data portion without any padding or offset
109109
const envelopeBytes = buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength);
110110
const envelope = new TextDecoder().decode(envelopeBytes);
111111
const piece = envelope.split('\n')[0];
112-
const header = JSON.parse(piece ?? '{}') as { dsn?: string };
112+
const header = JSON.parse(piece || '{}') as { dsn?: string };
113113
if (!header.dsn) {
114114
throw new Error('DSN is not set');
115115
}
@@ -133,11 +133,19 @@ export class AwsLambdaExtension {
133133
res.writeHead(500, { 'Content-Type': 'application/json' });
134134
res.end(JSON.stringify({ error: 'Error tunneling to Sentry' }));
135135
}
136+
} else {
137+
res.writeHead(404, { 'Content-Type': 'application/json' });
138+
res.end(JSON.stringify({ error: 'Not found' }));
136139
}
137140
});
138141

139142
server.listen(9000, () => {
140143
DEBUG_BUILD && debug.log('Sentry proxy listening on port 9000');
141144
});
145+
146+
server.on('error', err => {
147+
DEBUG_BUILD && debug.error('Error starting Sentry proxy', err);
148+
process.exit(1);
149+
});
142150
}
143151
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /