(monitor: Monitor)
| 424 | } |
| 425 | |
| 426 | function monitorServer(monitor: Monitor) { |
| 427 | return (callback: Callback) => { |
| 428 | if (monitor.s.state === STATE_MONITORING) { |
| 429 | queueMicrotask(callback); |
| 430 | return; |
| 431 | } |
| 432 | stateTransition(monitor, STATE_MONITORING); |
| 433 | function done() { |
| 434 | if (!isInCloseState(monitor)) { |
| 435 | stateTransition(monitor, STATE_IDLE); |
| 436 | } |
| 437 | |
| 438 | callback(); |
| 439 | } |
| 440 | |
| 441 | checkServer(monitor, (err, hello) => { |
| 442 | if (err) { |
| 443 | // otherwise an error occurred on initial discovery, also bail |
| 444 | if (monitor.server.description.type === ServerType.Unknown) { |
| 445 | return done(); |
| 446 | } |
| 447 | } |
| 448 | |
| 449 | // if the check indicates streaming is supported, immediately reschedule monitoring |
| 450 | if (useStreamingProtocol(monitor, hello?.topologyVersion)) { |
| 451 | setTimeout(() => { |
| 452 | if (!isInCloseState(monitor)) { |
| 453 | monitor.monitorId?.wake(); |
| 454 | } |
| 455 | }, 0); |
| 456 | } |
| 457 | |
| 458 | done(); |
| 459 | }); |
| 460 | }; |
| 461 | } |
| 462 | |
| 463 | function makeTopologyVersion(tv: TopologyVersion) { |
| 464 | return { |
no test coverage detected