I have a Teams meeting bot using Puppeteer that works perfectly fine locally but fails when deployed to Kubernetes. The bot get stuck and can not click on the button even though it found that button.
Quesitons:
What could cause this behavior difference between local and Kubernetes environments?
Are there specific Puppeteer configurations needed for Kubernetes deployments?
Could this be related to network idle or page load states?
Code Structure:
class Task {
async initMeeting() {
const { meetingUrl, userName } = this.taskData;
await this.page.goto(meetingUrl, {
waitUntil: 'load',
timeout: 0,
});
await this.enterUserNameAndJoin(userName);
}
async ensurePageReloaded() {
await Promise.all([
this.page.reload(),
waitForNetworkIdle(this.page, 1_000, 2),
]);
}
async enterUserNameAndJoin(userName) {
const nameToType = `${userName}'s Assistant`;
const selector = '[data-tid="prejoin-display-name-input"]';
await this.page.waitForSelector(selector, {
visible: true,
timeout: 10000
});
await typeInput(this.page, {
value: nameToType,
dataTid: 'prejoin-display-name-input',
});
await this.page.waitForTimeout(1000);
await clickButton(this.page, { ariaLabel: 'Join now' });
}
}
My waitForNetWorkIdle
const waitForNetworkIdle = (page, timeout, maxInflightRequests = 0) => {
page.on('request', onRequestStarted);
page.on('requestfinished', onRequestFinished);
page.on('requestfailed', onRequestFinished);
let inflight = 0;
let fulfill;
let promise = new Promise((x) => (fulfill = x));
let timeoutId = setTimeout(onTimeoutDone, timeout);
return promise;
function onTimeoutDone() {
page.removeListener('request', onRequestStarted);
page.removeListener('requestfinished', onRequestFinished);
page.removeListener('requestfailed', onRequestFinished);
fulfill();
}
function onRequestStarted() {
++inflight;
if (inflight > maxInflightRequests) clearTimeout(timeoutId);
}
function onRequestFinished() {
if (inflight === 0) return;
--inflight;
if (inflight === maxInflightRequests)
timeoutId = setTimeout(onTimeoutDone, timeout);
}
};
What I've Tried:
Increased timeouts Added delays between actions Verified network connectivity Checked for element visibility
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745606310a4635693.html
评论列表(0条)