@@ -7,7 +7,6 @@ import type { Disposable, SecretStorage } from "vscode";
77
88import type { Logger } from "../logging/logger" ;
99
10- const MESSAGE_MAX_AGE_MS = 5000 ;
1110const DEFAULT_PING_TIMEOUT_MS = 1000 ;
1211
1312const REQUEST_KEY = "coder.ipc.req" ;
@@ -17,21 +16,18 @@ const PingMessageSchema = z.object({
1716 type : z . literal ( "ping" ) ,
1817 id : z . string ( ) ,
1918 authority : z . string ( ) ,
20- ts : z . number ( ) ,
2119} ) ;
2220
2321const PongMessageSchema = z . object ( {
2422 type : z . literal ( "pong" ) ,
2523 id : z . string ( ) ,
2624 sessionId : z . string ( ) ,
27- ts : z . number ( ) ,
2825} ) ;
2926
3027const DuplicateMessageSchema = z . object ( {
3128 type : z . literal ( "duplicate" ) ,
3229 id : z . string ( ) ,
3330 targetSessionId : z . string ( ) ,
34- ts : z . number ( ) ,
3531} ) ;
3632
3733const RequestMessageSchema = z . discriminatedUnion ( "type" , [
@@ -104,7 +100,7 @@ export class DuplicateWorkspaceIpc {
104100 const timer = setTimeout ( ( ) => settle ( undefined ) , timeoutMs ) ;
105101
106102 this . requests
107- . send ( { type : "ping" , id, authority, ts : Date . now ( ) } )
103+ . send ( { type : "ping" , id, authority } )
108104 . then ( undefined , ( err : unknown ) => {
109105 this . logger . error ( "Failed to send IPC ping" , err ) ;
110106 settle ( undefined ) ;
@@ -117,7 +113,6 @@ export class DuplicateWorkspaceIpc {
117113 type : "pong" ,
118114 id : pingId ,
119115 sessionId,
120- ts : Date . now ( ) ,
121116 } ) ;
122117 }
123118
@@ -127,19 +122,12 @@ export class DuplicateWorkspaceIpc {
127122 type : "duplicate" ,
128123 id : crypto . randomUUID ( ) ,
129124 targetSessionId,
130- ts : Date . now ( ) ,
131125 } ) ;
132126 }
133127
134- /** Listen for incoming requests. Stale messages are dropped. */
135128 onRequest (
136129 handler : ( msg : RequestMessage ) => void | Promise < void > ,
137130 ) : Disposable {
138- return this . requests . onReceive ( ( msg ) => {
139- if ( Date . now ( ) - msg . ts > MESSAGE_MAX_AGE_MS ) {
140- return ;
141- }
142- return handler ( msg ) ;
143- } ) ;
131+ return this . requests . onReceive ( handler ) ;
144132 }
145133}
0 commit comments