Skip to content

Commit 5c08ef8

Browse files
committed
fix: remove unnecessary waiting for navigation
1 parent 67af3fe commit 5c08ef8

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
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 & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -126,18 +126,24 @@ export class WaitForHelper {
126126
async waitForEventsAfterAction(
127127
action: () => Promise<unknown>,
128128
): Promise<void> {
129-
const navigationStartedPromise = this.waitForNavigationStarted();
129+
const navigationFinished = 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+
);
130142

131143
await action();
132144

133145
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-
}
146+
await navigationFinished;
141147

142148
// Wait for stable dom after navigation so we execute in
143149
// the correct context

0 commit comments

Comments
 (0)