Skip to content

Commit b59ebe3

Browse files
committed
apply optimizations from review
1 parent 7f908d9 commit b59ebe3

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

.vscode/settings.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,8 @@
3333
"source.organizeImports.biome": true,
3434
"quickfix.biome": true
3535
},
36-
"editor.defaultFormatter": "biomejs.biome"
36+
"editor.defaultFormatter": "biomejs.biome",
37+
"[typescript]": {
38+
"editor.defaultFormatter": "biomejs.biome"
39+
}
3740
}

packages/astro/src/server/middleware.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,7 @@ async function instrumentRequest(
9191
}
9292
addNonEnumerableProperty(locals, '__sentry_wrapped__', true);
9393

94-
const method = ctx.request.method;
95-
const headers = ctx.request.headers;
94+
const { method, headers } = ctx.request;
9695

9796
const traceCtx = continueTrace({
9897
sentryTrace: headers.get('sentry-trace') || undefined,
@@ -160,10 +159,12 @@ async function instrumentRequest(
160159
return originalResponse;
161160
}
162161

162+
const decoder = new TextDecoder();
163+
163164
const newResponseStream = new ReadableStream({
164165
start: async controller => {
165166
for await (const chunk of originalBody) {
166-
const html = typeof chunk === 'string' ? chunk : new TextDecoder().decode(chunk);
167+
const html = typeof chunk === 'string' ? chunk : decoder.decode(chunk);
167168
const modifiedHtml = addMetaTagToHead(html, hub, span);
168169
controller.enqueue(new TextEncoder().encode(modifiedHtml));
169170
}

0 commit comments

Comments
 (0)