File tree Expand file tree Collapse file tree 1 file changed +7
-5
lines changed
packages/node/src/integrations/http Expand file tree Collapse file tree 1 file changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -140,6 +140,11 @@ export class SentryHttpInstrumentation extends InstrumentationBase<SentryHttpIns
140140 // eslint-disable-next-line @typescript-eslint/no-this-alias
141141 const instrumentation = this ;
142142
143+ // @ts -expect-error: FinalizationRegistry is not yet in the Node types
144+ const finalizationRegistry = new FinalizationRegistry ( ( isolationScope : Scope ) => {
145+ isolationScope . setSDKProcessingMetadata ( { normalizedRequest : undefined } ) ;
146+ } ) ;
147+
143148 return (
144149 original : ( event : string , ...args : unknown [ ] ) => boolean ,
145150 ) : ( ( this : unknown , event : string , ...args : unknown [ ] ) => boolean ) => {
@@ -183,11 +188,8 @@ export class SentryHttpInstrumentation extends InstrumentationBase<SentryHttpIns
183188 } ) ;
184189 }
185190
186- response . once ( 'close' , ( ) => {
187- // Remove normalized request from the scope after the response is finished
188- // This is to avoid keeping the request body in memory for too long.
189- isolationScope . setSDKProcessingMetadata ( { normalizedRequest : undefined } ) ;
190- } ) ;
191+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
192+ finalizationRegistry . register ( response , isolationScope ) ;
191193
192194 return withIsolationScope ( isolationScope , ( ) => {
193195 return withScope ( scope => {
You can’t perform that action at this time.
0 commit comments