File tree Expand file tree Collapse file tree 1 file changed +9
-7
lines changed Expand file tree Collapse file tree 1 file changed +9
-7
lines changed Original file line number Diff line number Diff line change @@ -11,8 +11,7 @@ import {
1111 OngoingRequest ,
1212 RawPassthroughEvent ,
1313 TlsConnectionEvent ,
14- TlsSocketMetadata ,
15- TlsTimingEvents
14+ TlsSocketMetadata
1615} from '../types' ;
1716
1817// We store a bunch of metadata that we directly attach to sockets, TLS
@@ -27,6 +26,11 @@ export const ClientErrorInProgress = Symbol('client-error-in-progress');
2726export const SocketTimingInfo = Symbol ( 'socket-timing-info' ) ;
2827export const SocketMetadata = Symbol ( 'socket-metadata' ) ;
2928
29+ export type SocketMetadata = {
30+ tags ?: string [ ] ;
31+ [ key : string ] : any ;
32+ }
33+
3034declare module 'net' {
3135 interface Socket {
3236 /**
@@ -78,10 +82,7 @@ declare module 'net' {
7882 * setup that will then be visible on all 'response' event data (for
7983 * example) later on.
8084 */
81- [ SocketMetadata ] ?: {
82- tags ?: string [ ] ;
83- [ key : string ] : any ;
84- }
85+ [ SocketMetadata ] ?: SocketMetadata ;
8586 }
8687}
8788
@@ -121,6 +122,7 @@ declare module 'http2' {
121122 [ LastHopEncrypted ] ?: net . Socket [ typeof LastHopEncrypted ] ;
122123 [ LastTunnelAddress ] ?: net . Socket [ typeof LastTunnelAddress ] ;
123124 [ SocketTimingInfo ] ?: net . Socket [ typeof SocketTimingInfo ] ;
125+ [ SocketMetadata ] ?: SocketMetadata ;
124126 }
125127}
126128
@@ -333,6 +335,6 @@ export function buildSocketTimingInfo(): Required<net.Socket>[typeof SocketTimin
333335 return { initialSocket : Date . now ( ) , initialSocketTimestamp : now ( ) } ;
334336}
335337
336- export function getSocketMetadataTags ( socket : net . Socket | undefined ) {
338+ export function getSocketMetadataTags ( socket : { [ SocketMetadata ] ?: SocketMetadata } | undefined ) {
337339 return ( socket ?. [ SocketMetadata ] ?. tags || [ ] ) . map ( ( tag : string ) => `socket-metadata:${ tag } ` ) ;
338340}
You can’t perform that action at this time.
0 commit comments