Skip to content

Commit 7e9c942

Browse files
committed
fix: remove unnecessary waiting for navigation
1 parent 67af3fe commit 7e9c942

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

src/McpContext.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,6 @@ export class McpContext implements Context {
364364
const networkMultiplier = getNetworkMultiplierFromString(
365365
this.getNetworkConditions(),
366366
);
367-
368367
const waitForHelper = this.getWaitForHelper(
369368
page,
370369
cpuMultiplier,

src/WaitForHelper.ts

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -126,18 +126,23 @@ export class WaitForHelper {
126126
async waitForEventsAfterAction(
127127
action: () => Promise<unknown>,
128128
): Promise<void> {
129-
const navigationStartedPromise = this.waitForNavigationStarted();
130-
129+
const navigationStartedPromise = this.waitForNavigationStarted().then(
130+
navigationStated => {
131+
if (navigationStated) {
132+
return this.#page
133+
.waitForNavigation({
134+
timeout: this.#navigationTimeout,
135+
signal: this.#abortController.signal,
136+
})
137+
.catch(error => logger(error));
138+
}
139+
return;
140+
},
141+
);
131142
await action();
132143

133144
try {
134-
const navigationStated = await navigationStartedPromise;
135-
if (navigationStated) {
136-
await this.#page.waitForNavigation({
137-
timeout: this.#navigationTimeout,
138-
signal: this.#abortController.signal,
139-
});
140-
}
145+
await navigationStartedPromise;
141146

142147
// Wait for stable dom after navigation so we execute in
143148
// the correct context

0 commit comments

Comments
 (0)