(data: any)
| 187 | }, session.config.timeout || 30000); |
| 188 | |
| 189 | const handleMessage = (data: any) => { |
| 190 | try { |
| 191 | const response = typeof data === 'string' ? JSON.parse(data) : data; |
| 192 | |
| 193 | if (response.id === message.id) { |
| 194 | clearTimeout(timeout); |
| 195 | connection.off?.('message', handleMessage); |
| 196 | |
| 197 | if (response.error) { |
| 198 | reject(new Error(response.error.message)); |
| 199 | } else { |
| 200 | resolve(response.result); |
| 201 | } |
| 202 | } |
| 203 | } catch (error) { |
| 204 | reject(error); |
| 205 | } |
| 206 | }; |
| 207 | |
| 208 | if (connection instanceof WebSocket) { |
| 209 | connection.on('message', handleMessage); |
no test coverage detected