Skip to content

Commit

Permalink
chore: wait for ok for pendingReconnect
Browse files Browse the repository at this point in the history
Signed-off-by: Case Wylie <[email protected]>
  • Loading branch information
cmwylie19 committed Nov 5, 2024
1 parent ab03054 commit 06b63d0
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/fluent/watch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -437,11 +437,11 @@ export class Watcher<T extends GenericClass> {
// Make the actual request
const response = await legacyFetch(url, { ...opts });

// Reset the pending reconnect flag
this.#pendingReconnect = false;

// If the request is successful, start listening for events
if (response.ok) {
// Reset the pending reconnect flag
this.#pendingReconnect = false;

this.#events.emit(WatchEvent.CONNECT, url.pathname);

const { body } = response;
Expand Down Expand Up @@ -518,11 +518,11 @@ export class Watcher<T extends GenericClass> {
dispatcher: Watcher.getHTTPSAgent(opts),
});

// Reset the pending reconnect flag
this.#pendingReconnect = false;

// If the request is successful, start listening for events
if (response.ok) {
// Reset the pending reconnect flag
this.#pendingReconnect = false;

this.#events.emit(WatchEvent.CONNECT, url.pathname);

const { body } = response;
Expand Down

0 comments on commit 06b63d0

Please sign in to comment.